Didn't we have some trouble in 2.1.7 with a similar patch?
Aleksandar Vidakovic wrote:
Salut all,
I had problems with schemas containing a dash in the name. SchemaExport
fails e. g. with a schema name like "component-security" on postgresql
(I'm sure that this is an issue on other DB systems, too). When I looked
into hibernates source I saw that table names can be quoted with
backticks, but schema names cannot. Is there a reason for this
behaviour...? I admit that I'm new to hibernate... at least concerning
it's source code ;-)
Attached you can find a little patch for the class
org.hibernate.mapping.Table which recognizes quoted schemas.
Cheers,
Aleks
------------------------------------------------------------------------
Index: Table.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate3/src/org/hibernate/mapping/Table.java,v
retrieving revision 1.33
diff -u -r1.33 Table.java
--- Table.java 11 Apr 2005 12:40:40 -0000 1.33
+++ Table.java 23 Apr 2005 15:04:44 -0000
@@ -38,6 +38,7 @@
private Map uniqueKeys = new HashMap();
private final int uniqueInteger;
private boolean quoted;
+ private boolean quotedSchema;
private static int tableCounter = 0;
private List checkConstraints = new ArrayList();
private String rowId;
@@ -78,7 +79,7 @@
public String getQualifiedName(Dialect dialect, String defaultCatalog,
String defaultSchema) {
if ( subselect != null ) return "( " + subselect + " )";
String quotedName = getQuotedName( dialect );
- String usedSchema = schema == null ? defaultSchema : schema;
+ String usedSchema = schema == null ? defaultSchema :
getQuotedSchema( dialect );
String usedCatalog = catalog == null ? defaultCatalog : catalog;
return Table.qualify( usedCatalog, usedSchema, quotedName,
dialect.getSchemaSeparator() );
}
@@ -109,6 +110,12 @@
name;
}
+ public String getQuotedSchema(Dialect dialect) {
+ return quotedSchema ?
+ dialect.openQuote() + schema +
dialect.closeQuote() :
+ schema;
+ }
+
public void setName(String name) {
if ( name.charAt( 0 ) == '`' ) {
quoted = true;
@@ -435,7 +442,13 @@
}
public void setSchema(String schema) {
- this.schema = schema;
+ if ( schema.charAt( 0 ) == '`' ) {
+ quotedSchema = true;
+ this.schema = schema.substring( 1, schema.length() - 1
);
+ }
+ else {
+ this.schema = schema;
+ }
}
public String getCatalog() {
--
Emmanuel Bernard
[EMAIL PROTECTED]
callto://emmanuelbernard
http://www.hibernate.org
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
hibernate-devel mailing list
hibernate-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hibernate-devel