Hibernate SVN: r10721 - branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-11-06 06:35:51 -0500 (Mon, 06 Nov 2006)
New Revision: 10721
Modified:
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/ASTParserLoadingTest.java
Log:
Updates for Ingres certification
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/ASTParserLoadingTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/ASTParserLoadingTest.java 2006-11-06 11:35:40 UTC (rev 10720)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/ASTParserLoadingTest.java 2006-11-06 11:35:51 UTC (rev 10721)
@@ -1550,7 +1550,9 @@
}
public void testSubselectBetween() {
- assertResultSize("from Animal x where (select max(a.bodyWeight) from Animal a) in (1,2,3)", 0);
+ if(supportsSubselectOnLeftSideIn()) {
+ assertResultSize("from Animal x where (select max(a.bodyWeight) from Animal a) in (1,2,3)", 0);
+ }
assertResultSize("from Animal x where (select max(a.bodyWeight) from Animal a) between 0 and 100", 0);
assertResultSize("from Animal x where (select max(a.description) from Animal a) like 'big%'", 0);
assertResultSize("from Animal x where (select max(a.bodyWeight) from Animal a) is not null", 0);
18 years, 2 months
Hibernate SVN: r10720 - trunk/Hibernate3/src/org/hibernate/engine
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-11-06 06:35:40 -0500 (Mon, 06 Nov 2006)
New Revision: 10720
Modified:
trunk/Hibernate3/src/org/hibernate/engine/Cascade.java
Log:
rollback
Modified: trunk/Hibernate3/src/org/hibernate/engine/Cascade.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/engine/Cascade.java 2006-11-06 11:27:36 UTC (rev 10719)
+++ trunk/Hibernate3/src/org/hibernate/engine/Cascade.java 2006-11-06 11:35:40 UTC (rev 10720)
@@ -12,7 +12,6 @@
import org.hibernate.event.EventSource;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.entity.EntityPersister;
-import org.hibernate.pretty.MessageHelper;
import org.hibernate.type.AbstractComponentType;
import org.hibernate.type.AssociationType;
import org.hibernate.type.CollectionType;
@@ -113,7 +112,7 @@
if ( persister.hasCascades() || action.requiresNoCascadeChecking() ) { // performance opt
if ( log.isTraceEnabled() ) {
- log.trace( "processing cascade " + action + " for: " + MessageHelper.infoString( persister, persister.getIdentifier( parent, eventSource.getEntityMode() ), persister.getFactory() ) );
+ log.trace( "processing cascade " + action + " for: " + persister.getEntityName() );
}
Type[] types = persister.getPropertyTypes();
@@ -128,13 +127,8 @@
}
if ( style.doCascade( action ) ) {
- Object propertyValue = persister.getPropertyValue( parent, i, entityMode );
- if(log.isTraceEnabled()) {
- log.trace( "cascading " + action + " via property " + persister.getPropertyNames()[i] + " of type " + types[i].getName() + " with " + (propertyValue==null?" null value":"value"));
- }
-
cascadeProperty(
- propertyValue,
+ persister.getPropertyValue( parent, i, entityMode ),
types[i],
style,
anything,
@@ -142,9 +136,6 @@
);
}
else if ( action.requiresNoCascadeChecking() ) {
- if(log.isTraceEnabled()) {
- log.trace( "no-cascading " + action + " via property " + persister.getPropertyNames()[i] + " of type " + types[i].getName());
- }
action.noCascade(
eventSource,
persister.getPropertyValue( parent, i, entityMode ),
@@ -156,10 +147,8 @@
}
if ( log.isTraceEnabled() ) {
- log.trace( "done processing cascade " + action + " for: " + MessageHelper.infoString( persister, persister.getIdentifier( parent, eventSource.getEntityMode() ), persister.getFactory() ) );
+ log.trace( "done processing cascade " + action + " for: " + persister.getEntityName() );
}
- } else {
- // log skipped cascading ?
}
}
18 years, 2 months
Hibernate SVN: r10719 - in trunk/Hibernate3: etc src/org/hibernate/dialect src/org/hibernate/engine test/org/hibernate/test test/org/hibernate/test/bidi
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-11-06 06:27:36 -0500 (Mon, 06 Nov 2006)
New Revision: 10719
Modified:
trunk/Hibernate3/etc/hibernate.properties
trunk/Hibernate3/src/org/hibernate/dialect/IngresDialect.java
trunk/Hibernate3/src/org/hibernate/engine/Cascade.java
trunk/Hibernate3/test/org/hibernate/test/TestCase.java
trunk/Hibernate3/test/org/hibernate/test/bidi/Auction.hbm.xml
trunk/Hibernate3/test/org/hibernate/test/bidi/Auction2.hbm.xml
Log:
Updates for Ingres certification (merge from 3.2)
Modified: trunk/Hibernate3/etc/hibernate.properties
===================================================================
--- trunk/Hibernate3/etc/hibernate.properties 2006-11-06 11:15:42 UTC (rev 10718)
+++ trunk/Hibernate3/etc/hibernate.properties 2006-11-06 11:27:36 UTC (rev 10719)
@@ -208,13 +208,22 @@
## Ingres
-#hibernate.dialect org.hibernate.dialect.IngresDialect
-#hibernate.connection.driver_class ca.edbc.jdbc.EdbcDriver
-#hibernate.connection.url jdbc:edbc://localhost:II7/database
-#hibernate.connection.username user
+## older versions (before Ingress 2006)
+
+#hibernate.dialect org.hibernate.dialect.IngresDialect
+#hibernate.connection.driver_class ca.edbc.jdbc.EdbcDriver
+#hibernate.connection.url jdbc:edbc://localhost:II7/database
+#hibernate.connection.username user
#hibernate.connection.password password
+## Ingres 2006 or later
+#hibernate.dialect org.hibernate.dialect.IngresDialect
+#hibernate.connection.driver_class com.ingres.jdbc.IngresDriver
+#hibernate.connection.url jdbc:ingres://localhost:II7/database;CURSOR=READONLY;auto=multi
+#hibernate.connection.username user
+#hibernate.connection.password password
+
## Mimer SQL
#hibernate.dialect org.hibernate.dialect.MimerSQLDialect
Modified: trunk/Hibernate3/src/org/hibernate/dialect/IngresDialect.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/dialect/IngresDialect.java 2006-11-06 11:15:42 UTC (rev 10718)
+++ trunk/Hibernate3/src/org/hibernate/dialect/IngresDialect.java 2006-11-06 11:27:36 UTC (rev 10719)
@@ -4,13 +4,20 @@
import java.sql.Types;
import org.hibernate.Hibernate;
+import org.hibernate.dialect.function.SQLFunctionTemplate;
import org.hibernate.dialect.function.NoArgSQLFunction;
import org.hibernate.dialect.function.StandardSQLFunction;
+import org.hibernate.dialect.function.VarArgsSQLFunction;
/**
- * An Ingres SQL dialect
- * @author Ian Booth, Bruce Lunsford
+ * An Ingres SQL dialect.
+ *
+ * Known limitations:
+ * - only supports simple constants or columns on the left side of an IN, making (1,2,3) in (...) or (<subselect) in (...) non-supported
+ * - supports only 31 digits in decimal
+ *
+ * @author Ian Booth, Bruce Lunsford, Max Rydahl Andersen
*/
public class IngresDialect extends Dialect {
@@ -24,8 +31,8 @@
registerColumnType( Types.REAL, "real" );
registerColumnType( Types.FLOAT, "float" );
registerColumnType( Types.DOUBLE, "float" );
- registerColumnType( Types.NUMERIC, "decimal(19, $l)" );
- registerColumnType( Types.DECIMAL, "decimal(19, $l)" );
+ registerColumnType( Types.NUMERIC, "decimal($p, $s)" );
+ registerColumnType( Types.DECIMAL, "decimal($p, $s)" );
registerColumnType( Types.BINARY, 32000, "byte($l)" );
registerColumnType( Types.BINARY, "long byte" );
registerColumnType( Types.VARBINARY, 32000, "varbyte($l)" );
@@ -51,25 +58,33 @@
registerFunction( "bit_xor", new StandardSQLFunction("bit_xor") );
registerFunction( "character_length", new StandardSQLFunction( "character_length", Hibernate.LONG ) );
registerFunction( "charextract", new StandardSQLFunction( "charextract", Hibernate.STRING ) );
- registerFunction( "concat", new StandardSQLFunction( "concat", Hibernate.STRING ) );
+ registerFunction( "concat", new VarArgsSQLFunction( Hibernate.STRING, "(","+",")" ) );
registerFunction( "cos", new StandardSQLFunction( "cos", Hibernate.DOUBLE ) );
registerFunction( "current_user", new NoArgSQLFunction( "current_user", Hibernate.STRING, false ) );
+ registerFunction( "current_time", new NoArgSQLFunction("date('now')", Hibernate.TIMESTAMP, false) );
+ registerFunction( "current_timestamp", new NoArgSQLFunction("date('now')", Hibernate.TIMESTAMP, false) );
+ registerFunction( "current_date", new NoArgSQLFunction("date('now')", Hibernate.TIMESTAMP, false) );
registerFunction( "date_trunc", new StandardSQLFunction( "date_trunc", Hibernate.TIMESTAMP ) );
+ registerFunction( "day", new StandardSQLFunction("day", Hibernate.INTEGER) );
registerFunction( "dba", new NoArgSQLFunction( "dba", Hibernate.STRING, true ) );
registerFunction( "dow", new StandardSQLFunction( "dow", Hibernate.STRING ) );
+ registerFunction( "extract", new SQLFunctionTemplate( Hibernate.INTEGER, "date_part('?1', ?3)" ) );
registerFunction( "exp", new StandardSQLFunction( "exp", Hibernate.DOUBLE ) );
registerFunction( "gmt_timestamp", new StandardSQLFunction( "gmt_timestamp", Hibernate.STRING ) );
registerFunction( "hash", new StandardSQLFunction( "hash", Hibernate.INTEGER ) );
registerFunction( "hex", new StandardSQLFunction( "hex", Hibernate.STRING ) );
+ registerFunction( "hour", new StandardSQLFunction("hour", Hibernate.INTEGER) );
registerFunction( "initial_user", new NoArgSQLFunction( "initial_user", Hibernate.STRING, false ) );
registerFunction( "intextract", new StandardSQLFunction( "intextract", Hibernate.INTEGER ) );
registerFunction( "left", new StandardSQLFunction( "left", Hibernate.STRING ) );
- registerFunction( "locate", new StandardSQLFunction( "locate", Hibernate.LONG ) );
+ registerFunction( "locate", new SQLFunctionTemplate( Hibernate.LONG, "locate(?1, ?2)" ) );
registerFunction( "length", new StandardSQLFunction( "length", Hibernate.LONG ) );
registerFunction( "ln", new StandardSQLFunction( "ln", Hibernate.DOUBLE ) );
registerFunction( "log", new StandardSQLFunction( "log", Hibernate.DOUBLE ) );
registerFunction( "lower", new StandardSQLFunction("lower") );
registerFunction( "lowercase", new StandardSQLFunction("lowercase") );
+ registerFunction( "minute", new StandardSQLFunction("minute", Hibernate.INTEGER) );
+ registerFunction( "month", new StandardSQLFunction("month", Hibernate.INTEGER) );
registerFunction( "octet_length", new StandardSQLFunction( "octet_length", Hibernate.LONG ) );
registerFunction( "pad", new StandardSQLFunction( "pad", Hibernate.STRING ) );
registerFunction( "position", new StandardSQLFunction( "position", Hibernate.LONG ) );
@@ -78,13 +93,15 @@
registerFunction( "randomf", new NoArgSQLFunction( "randomf", Hibernate.DOUBLE, true ) );
registerFunction( "right", new StandardSQLFunction( "right", Hibernate.STRING ) );
registerFunction( "session_user", new NoArgSQLFunction( "session_user", Hibernate.STRING, false ) );
+ registerFunction( "second", new StandardSQLFunction("second", Hibernate.INTEGER) );
registerFunction( "size", new NoArgSQLFunction( "size", Hibernate.LONG, true ) );
registerFunction( "squeeze", new StandardSQLFunction("squeeze") );
registerFunction( "sin", new StandardSQLFunction( "sin", Hibernate.DOUBLE ) );
registerFunction( "soundex", new StandardSQLFunction( "soundex", Hibernate.STRING ) );
registerFunction( "sqrt", new StandardSQLFunction( "sqrt", Hibernate.DOUBLE ) );
+ registerFunction( "substring", new SQLFunctionTemplate( Hibernate.STRING, "substring(?1 FROM ?2 FOR ?3)" ) );
registerFunction( "system_user", new NoArgSQLFunction( "system_user", Hibernate.STRING, false ) );
- registerFunction( "trim", new StandardSQLFunction("trim") );
+ registerFunction( "trim", new StandardSQLFunction("trim", Hibernate.STRING ) );
registerFunction( "unhex", new StandardSQLFunction( "unhex", Hibernate.STRING ) );
registerFunction( "upper", new StandardSQLFunction("upper") );
registerFunction( "uppercase", new StandardSQLFunction("uppercase") );
@@ -95,6 +112,7 @@
registerFunction( "uuid_compare", new StandardSQLFunction( "uuid_compare", Hibernate.INTEGER ) );
registerFunction( "uuid_from_char", new StandardSQLFunction( "uuid_from_char", Hibernate.BYTE ) );
registerFunction( "uuid_to_char", new StandardSQLFunction( "uuid_to_char", Hibernate.STRING ) );
+ registerFunction( "year", new StandardSQLFunction("year", Hibernate.INTEGER) );
}
/**
@@ -222,5 +240,37 @@
public boolean useMaxForLimit() {
return true;
}
+ /**
+ * Ingres explicitly needs "unique not null", because "with null" is default
+ */
+ public boolean supportsNotNullUnique() {
+ return false;
+ }
+
+ /**
+ * Does this dialect support temporary tables?
+ */
+ public boolean supportsTemporaryTables() {
+ return true;
+ }
+
+ public String getCreateTemporaryTableString() {
+ return "declare global temporary table";
+ }
+
+ public String getCreateTemporaryTablePostfix() {
+ return "on commit preserve rows with norecovery";
+ }
+
+ public String generateTemporaryTableName(String baseTableName) {
+ return "session." + super.generateTemporaryTableName(baseTableName);
+ }
+
+ /**
+ * Expression for current_timestamp
+ */
+ public String getCurrentTimestampSQLFunctionName() {
+ return "date(now)";
+ }
}
Modified: trunk/Hibernate3/src/org/hibernate/engine/Cascade.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/engine/Cascade.java 2006-11-06 11:15:42 UTC (rev 10718)
+++ trunk/Hibernate3/src/org/hibernate/engine/Cascade.java 2006-11-06 11:27:36 UTC (rev 10719)
@@ -12,6 +12,7 @@
import org.hibernate.event.EventSource;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.entity.EntityPersister;
+import org.hibernate.pretty.MessageHelper;
import org.hibernate.type.AbstractComponentType;
import org.hibernate.type.AssociationType;
import org.hibernate.type.CollectionType;
@@ -112,7 +113,7 @@
if ( persister.hasCascades() || action.requiresNoCascadeChecking() ) { // performance opt
if ( log.isTraceEnabled() ) {
- log.trace( "processing cascade " + action + " for: " + persister.getEntityName() );
+ log.trace( "processing cascade " + action + " for: " + MessageHelper.infoString( persister, persister.getIdentifier( parent, eventSource.getEntityMode() ), persister.getFactory() ) );
}
Type[] types = persister.getPropertyTypes();
@@ -127,8 +128,13 @@
}
if ( style.doCascade( action ) ) {
+ Object propertyValue = persister.getPropertyValue( parent, i, entityMode );
+ if(log.isTraceEnabled()) {
+ log.trace( "cascading " + action + " via property " + persister.getPropertyNames()[i] + " of type " + types[i].getName() + " with " + (propertyValue==null?" null value":"value"));
+ }
+
cascadeProperty(
- persister.getPropertyValue( parent, i, entityMode ),
+ propertyValue,
types[i],
style,
anything,
@@ -136,6 +142,9 @@
);
}
else if ( action.requiresNoCascadeChecking() ) {
+ if(log.isTraceEnabled()) {
+ log.trace( "no-cascading " + action + " via property " + persister.getPropertyNames()[i] + " of type " + types[i].getName());
+ }
action.noCascade(
eventSource,
persister.getPropertyValue( parent, i, entityMode ),
@@ -147,8 +156,10 @@
}
if ( log.isTraceEnabled() ) {
- log.trace( "done processing cascade " + action + " for: " + persister.getEntityName() );
+ log.trace( "done processing cascade " + action + " for: " + MessageHelper.infoString( persister, persister.getIdentifier( parent, eventSource.getEntityMode() ), persister.getFactory() ) );
}
+ } else {
+ // log skipped cascading ?
}
}
Modified: trunk/Hibernate3/test/org/hibernate/test/TestCase.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/TestCase.java 2006-11-06 11:15:42 UTC (rev 10718)
+++ trunk/Hibernate3/test/org/hibernate/test/TestCase.java 2006-11-06 11:27:36 UTC (rev 10719)
@@ -21,6 +21,7 @@
import org.hibernate.dialect.DB2Dialect;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.HSQLDialect;
+import org.hibernate.dialect.IngresDialect;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.Oracle9Dialect;
import org.hibernate.dialect.PostgreSQLDialect;
@@ -542,7 +543,20 @@
}
return true;
}
+
+ protected boolean supportsSubselectOnLeftSideIn() {
+ if (dialectIsNot( IngresDialect.class )) {
+ return true;
+ } else {
+ reportSkip( "Database does not support (<subselect>) in ( ... ) ", "query support" );
+ return false;
+ }
+ }
+ private boolean dialectIsNot(Class dialectClass) {
+ return dialectIsNot( new Class[] { dialectClass } );
+ }
+
private boolean dialectIsNot(Class[] dialectClasses) {
for (int i = 0; i < dialectClasses.length; i++) {
Class dialectClass = dialectClasses[i];
Modified: trunk/Hibernate3/test/org/hibernate/test/bidi/Auction.hbm.xml
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/bidi/Auction.hbm.xml 2006-11-06 11:15:42 UTC (rev 10718)
+++ trunk/Hibernate3/test/org/hibernate/test/bidi/Auction.hbm.xml 2006-11-06 11:27:36 UTC (rev 10719)
@@ -30,7 +30,7 @@
</id>
<property name="amount"
scale="19"
- precision="38" />
+ precision="31" />
<property name="datetime"
column="createdDatetime"/>
<properties name="abc">
Modified: trunk/Hibernate3/test/org/hibernate/test/bidi/Auction2.hbm.xml
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/bidi/Auction2.hbm.xml 2006-11-06 11:15:42 UTC (rev 10718)
+++ trunk/Hibernate3/test/org/hibernate/test/bidi/Auction2.hbm.xml 2006-11-06 11:27:36 UTC (rev 10719)
@@ -24,7 +24,7 @@
<id name="id">
<generator class="native"/>
</id>
- <property name="amount" scale="19" precision="38"/>
+ <property name="amount" scale="19" precision="31"/>
<property name="datetime"
column="createdDatetime"/>
<many-to-one name="item"
18 years, 2 months
Hibernate SVN: r10718 - in branches/Branch_3_2/Hibernate3: etc src/org/hibernate/dialect test/org/hibernate/test test/org/hibernate/test/bidi
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-11-06 06:15:42 -0500 (Mon, 06 Nov 2006)
New Revision: 10718
Modified:
branches/Branch_3_2/Hibernate3/etc/hibernate.properties
branches/Branch_3_2/Hibernate3/src/org/hibernate/dialect/IngresDialect.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/TestCase.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bidi/Auction.hbm.xml
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bidi/Auction2.hbm.xml
Log:
Updates for Ingres certification
Modified: branches/Branch_3_2/Hibernate3/etc/hibernate.properties
===================================================================
--- branches/Branch_3_2/Hibernate3/etc/hibernate.properties 2006-11-03 19:05:21 UTC (rev 10717)
+++ branches/Branch_3_2/Hibernate3/etc/hibernate.properties 2006-11-06 11:15:42 UTC (rev 10718)
@@ -208,13 +208,22 @@
## Ingres
-#hibernate.dialect org.hibernate.dialect.IngresDialect
-#hibernate.connection.driver_class ca.edbc.jdbc.EdbcDriver
-#hibernate.connection.url jdbc:edbc://localhost:II7/database
-#hibernate.connection.username user
+## older versions (before Ingress 2006)
+
+#hibernate.dialect org.hibernate.dialect.IngresDialect
+#hibernate.connection.driver_class ca.edbc.jdbc.EdbcDriver
+#hibernate.connection.url jdbc:edbc://localhost:II7/database
+#hibernate.connection.username user
#hibernate.connection.password password
+## Ingres 2006 or later
+#hibernate.dialect org.hibernate.dialect.IngresDialect
+#hibernate.connection.driver_class com.ingres.jdbc.IngresDriver
+#hibernate.connection.url jdbc:ingres://localhost:II7/database;CURSOR=READONLY;auto=multi
+#hibernate.connection.username user
+#hibernate.connection.password password
+
## Mimer SQL
#hibernate.dialect org.hibernate.dialect.MimerSQLDialect
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/dialect/IngresDialect.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/dialect/IngresDialect.java 2006-11-03 19:05:21 UTC (rev 10717)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/dialect/IngresDialect.java 2006-11-06 11:15:42 UTC (rev 10718)
@@ -4,13 +4,20 @@
import java.sql.Types;
import org.hibernate.Hibernate;
+import org.hibernate.dialect.function.SQLFunctionTemplate;
import org.hibernate.dialect.function.NoArgSQLFunction;
import org.hibernate.dialect.function.StandardSQLFunction;
+import org.hibernate.dialect.function.VarArgsSQLFunction;
/**
- * An Ingres SQL dialect
- * @author Ian Booth, Bruce Lunsford
+ * An Ingres SQL dialect.
+ *
+ * Known limitations:
+ * - only supports simple constants or columns on the left side of an IN, making (1,2,3) in (...) or (<subselect) in (...) non-supported
+ * - supports only 31 digits in decimal
+ *
+ * @author Ian Booth, Bruce Lunsford, Max Rydahl Andersen
*/
public class IngresDialect extends Dialect {
@@ -24,8 +31,8 @@
registerColumnType( Types.REAL, "real" );
registerColumnType( Types.FLOAT, "float" );
registerColumnType( Types.DOUBLE, "float" );
- registerColumnType( Types.NUMERIC, "decimal(19, $l)" );
- registerColumnType( Types.DECIMAL, "decimal(19, $l)" );
+ registerColumnType( Types.NUMERIC, "decimal($p, $s)" );
+ registerColumnType( Types.DECIMAL, "decimal($p, $s)" );
registerColumnType( Types.BINARY, 32000, "byte($l)" );
registerColumnType( Types.BINARY, "long byte" );
registerColumnType( Types.VARBINARY, 32000, "varbyte($l)" );
@@ -51,25 +58,33 @@
registerFunction( "bit_xor", new StandardSQLFunction("bit_xor") );
registerFunction( "character_length", new StandardSQLFunction( "character_length", Hibernate.LONG ) );
registerFunction( "charextract", new StandardSQLFunction( "charextract", Hibernate.STRING ) );
- registerFunction( "concat", new StandardSQLFunction( "concat", Hibernate.STRING ) );
+ registerFunction( "concat", new VarArgsSQLFunction( Hibernate.STRING, "(","+",")" ) );
registerFunction( "cos", new StandardSQLFunction( "cos", Hibernate.DOUBLE ) );
registerFunction( "current_user", new NoArgSQLFunction( "current_user", Hibernate.STRING, false ) );
+ registerFunction( "current_time", new NoArgSQLFunction("date('now')", Hibernate.TIMESTAMP, false) );
+ registerFunction( "current_timestamp", new NoArgSQLFunction("date('now')", Hibernate.TIMESTAMP, false) );
+ registerFunction( "current_date", new NoArgSQLFunction("date('now')", Hibernate.TIMESTAMP, false) );
registerFunction( "date_trunc", new StandardSQLFunction( "date_trunc", Hibernate.TIMESTAMP ) );
+ registerFunction( "day", new StandardSQLFunction("day", Hibernate.INTEGER) );
registerFunction( "dba", new NoArgSQLFunction( "dba", Hibernate.STRING, true ) );
registerFunction( "dow", new StandardSQLFunction( "dow", Hibernate.STRING ) );
+ registerFunction( "extract", new SQLFunctionTemplate( Hibernate.INTEGER, "date_part('?1', ?3)" ) );
registerFunction( "exp", new StandardSQLFunction( "exp", Hibernate.DOUBLE ) );
registerFunction( "gmt_timestamp", new StandardSQLFunction( "gmt_timestamp", Hibernate.STRING ) );
registerFunction( "hash", new StandardSQLFunction( "hash", Hibernate.INTEGER ) );
registerFunction( "hex", new StandardSQLFunction( "hex", Hibernate.STRING ) );
+ registerFunction( "hour", new StandardSQLFunction("hour", Hibernate.INTEGER) );
registerFunction( "initial_user", new NoArgSQLFunction( "initial_user", Hibernate.STRING, false ) );
registerFunction( "intextract", new StandardSQLFunction( "intextract", Hibernate.INTEGER ) );
registerFunction( "left", new StandardSQLFunction( "left", Hibernate.STRING ) );
- registerFunction( "locate", new StandardSQLFunction( "locate", Hibernate.LONG ) );
+ registerFunction( "locate", new SQLFunctionTemplate( Hibernate.LONG, "locate(?1, ?2)" ) );
registerFunction( "length", new StandardSQLFunction( "length", Hibernate.LONG ) );
registerFunction( "ln", new StandardSQLFunction( "ln", Hibernate.DOUBLE ) );
registerFunction( "log", new StandardSQLFunction( "log", Hibernate.DOUBLE ) );
registerFunction( "lower", new StandardSQLFunction("lower") );
registerFunction( "lowercase", new StandardSQLFunction("lowercase") );
+ registerFunction( "minute", new StandardSQLFunction("minute", Hibernate.INTEGER) );
+ registerFunction( "month", new StandardSQLFunction("month", Hibernate.INTEGER) );
registerFunction( "octet_length", new StandardSQLFunction( "octet_length", Hibernate.LONG ) );
registerFunction( "pad", new StandardSQLFunction( "pad", Hibernate.STRING ) );
registerFunction( "position", new StandardSQLFunction( "position", Hibernate.LONG ) );
@@ -78,13 +93,15 @@
registerFunction( "randomf", new NoArgSQLFunction( "randomf", Hibernate.DOUBLE, true ) );
registerFunction( "right", new StandardSQLFunction( "right", Hibernate.STRING ) );
registerFunction( "session_user", new NoArgSQLFunction( "session_user", Hibernate.STRING, false ) );
+ registerFunction( "second", new StandardSQLFunction("second", Hibernate.INTEGER) );
registerFunction( "size", new NoArgSQLFunction( "size", Hibernate.LONG, true ) );
registerFunction( "squeeze", new StandardSQLFunction("squeeze") );
registerFunction( "sin", new StandardSQLFunction( "sin", Hibernate.DOUBLE ) );
registerFunction( "soundex", new StandardSQLFunction( "soundex", Hibernate.STRING ) );
registerFunction( "sqrt", new StandardSQLFunction( "sqrt", Hibernate.DOUBLE ) );
+ registerFunction( "substring", new SQLFunctionTemplate( Hibernate.STRING, "substring(?1 FROM ?2 FOR ?3)" ) );
registerFunction( "system_user", new NoArgSQLFunction( "system_user", Hibernate.STRING, false ) );
- registerFunction( "trim", new StandardSQLFunction("trim") );
+ registerFunction( "trim", new StandardSQLFunction("trim", Hibernate.STRING ) );
registerFunction( "unhex", new StandardSQLFunction( "unhex", Hibernate.STRING ) );
registerFunction( "upper", new StandardSQLFunction("upper") );
registerFunction( "uppercase", new StandardSQLFunction("uppercase") );
@@ -95,6 +112,7 @@
registerFunction( "uuid_compare", new StandardSQLFunction( "uuid_compare", Hibernate.INTEGER ) );
registerFunction( "uuid_from_char", new StandardSQLFunction( "uuid_from_char", Hibernate.BYTE ) );
registerFunction( "uuid_to_char", new StandardSQLFunction( "uuid_to_char", Hibernate.STRING ) );
+ registerFunction( "year", new StandardSQLFunction("year", Hibernate.INTEGER) );
}
/**
@@ -222,5 +240,37 @@
public boolean useMaxForLimit() {
return true;
}
+ /**
+ * Ingres explicitly needs "unique not null", because "with null" is default
+ */
+ public boolean supportsNotNullUnique() {
+ return false;
+ }
+
+ /**
+ * Does this dialect support temporary tables?
+ */
+ public boolean supportsTemporaryTables() {
+ return true;
+ }
+
+ public String getCreateTemporaryTableString() {
+ return "declare global temporary table";
+ }
+
+ public String getCreateTemporaryTablePostfix() {
+ return "on commit preserve rows with norecovery";
+ }
+
+ public String generateTemporaryTableName(String baseTableName) {
+ return "session." + super.generateTemporaryTableName(baseTableName);
+ }
+
+ /**
+ * Expression for current_timestamp
+ */
+ public String getCurrentTimestampSQLFunctionName() {
+ return "date(now)";
+ }
}
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/TestCase.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/TestCase.java 2006-11-03 19:05:21 UTC (rev 10717)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/TestCase.java 2006-11-06 11:15:42 UTC (rev 10718)
@@ -21,6 +21,7 @@
import org.hibernate.dialect.DB2Dialect;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.HSQLDialect;
+import org.hibernate.dialect.IngresDialect;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.Oracle9Dialect;
import org.hibernate.dialect.PostgreSQLDialect;
@@ -546,7 +547,20 @@
}
return true;
}
+
+ protected boolean supportsSubselectOnLeftSideIn() {
+ if (dialectIsNot( IngresDialect.class )) {
+ return true;
+ } else {
+ reportSkip( "Database does not support (<subselect>) in ( ... ) ", "query support" );
+ return false;
+ }
+ }
+ private boolean dialectIsNot(Class dialectClass) {
+ return dialectIsNot( new Class[] { dialectClass } );
+ }
+
private boolean dialectIsNot(Class[] dialectClasses) {
for (int i = 0; i < dialectClasses.length; i++) {
Class dialectClass = dialectClasses[i];
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bidi/Auction.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bidi/Auction.hbm.xml 2006-11-03 19:05:21 UTC (rev 10717)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bidi/Auction.hbm.xml 2006-11-06 11:15:42 UTC (rev 10718)
@@ -30,7 +30,7 @@
</id>
<property name="amount"
scale="19"
- precision="38" />
+ precision="31" />
<property name="datetime"
column="createdDatetime"/>
<properties name="abc">
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bidi/Auction2.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bidi/Auction2.hbm.xml 2006-11-03 19:05:21 UTC (rev 10717)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bidi/Auction2.hbm.xml 2006-11-06 11:15:42 UTC (rev 10718)
@@ -24,7 +24,7 @@
<id name="id">
<generator class="native"/>
</id>
- <property name="amount" scale="19" precision="38"/>
+ <property name="amount" scale="19" precision="31"/>
<property name="datetime"
column="createdDatetime"/>
<many-to-one name="item"
18 years, 2 months
Hibernate SVN: r10717 - in trunk/Hibernate3: lib src/org/hibernate/cache
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-11-03 14:05:21 -0500 (Fri, 03 Nov 2006)
New Revision: 10717
Added:
trunk/Hibernate3/lib/ehcache-1.2.3.jar
Modified:
trunk/Hibernate3/lib/version.properties
trunk/Hibernate3/src/org/hibernate/cache/EhCache.java
Log:
HHH-2209 ehcache.jar is old and does not contain the SingletonCacheProvider which are advised in exception messages
Added: trunk/Hibernate3/lib/ehcache-1.2.3.jar
===================================================================
(Binary files differ)
Property changes on: trunk/Hibernate3/lib/ehcache-1.2.3.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/Hibernate3/lib/version.properties
===================================================================
--- trunk/Hibernate3/lib/version.properties 2006-11-03 19:05:11 UTC (rev 10716)
+++ trunk/Hibernate3/lib/version.properties 2006-11-03 19:05:21 UTC (rev 10717)
@@ -159,8 +159,8 @@
## cache providers
-ehcache.lib=ehcache-1.2.jar
-ehcache.version=1.2
+ehcache.lib=ehcache-1.2.3.jar
+ehcache.version=1.2.3
ehcache.name=EHCache cache
ehcache.when=runtime, optional (required if no other cache provider is set)
Modified: trunk/Hibernate3/src/org/hibernate/cache/EhCache.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/cache/EhCache.java 2006-11-03 19:05:11 UTC (rev 10716)
+++ trunk/Hibernate3/src/org/hibernate/cache/EhCache.java 2006-11-03 19:05:21 UTC (rev 10717)
@@ -124,6 +124,9 @@
catch (IllegalStateException e) {
throw new CacheException( e );
}
+ catch (net.sf.ehcache.CacheException e) {
+ throw new CacheException( e );
+ }
}
@@ -145,6 +148,9 @@
catch (IllegalStateException e) {
throw new CacheException( e );
}
+ catch (net.sf.ehcache.CacheException e) {
+ throw new CacheException( e );
+ }
}
/**
@@ -160,7 +166,7 @@
catch (IllegalStateException e) {
throw new CacheException( e );
}
- catch (IOException e) {
+ catch (net.sf.ehcache.CacheException e) {
throw new CacheException( e );
}
}
18 years, 2 months
Hibernate SVN: r10716 - in branches/Branch_3_2/Hibernate3: lib src/org/hibernate/cache
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-11-03 14:05:11 -0500 (Fri, 03 Nov 2006)
New Revision: 10716
Added:
branches/Branch_3_2/Hibernate3/lib/ehcache-1.2.3.jar
Modified:
branches/Branch_3_2/Hibernate3/lib/version.properties
branches/Branch_3_2/Hibernate3/src/org/hibernate/cache/EhCache.java
Log:
HHH-2209 ehcache.jar is old and does not contain the SingletonCacheProvider which are advised in exception messages
Added: branches/Branch_3_2/Hibernate3/lib/ehcache-1.2.3.jar
===================================================================
(Binary files differ)
Property changes on: branches/Branch_3_2/Hibernate3/lib/ehcache-1.2.3.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: branches/Branch_3_2/Hibernate3/lib/version.properties
===================================================================
--- branches/Branch_3_2/Hibernate3/lib/version.properties 2006-11-03 16:23:21 UTC (rev 10715)
+++ branches/Branch_3_2/Hibernate3/lib/version.properties 2006-11-03 19:05:11 UTC (rev 10716)
@@ -159,8 +159,8 @@
## cache providers
-ehcache.lib=ehcache-1.2.jar
-ehcache.version=1.2
+ehcache.lib=ehcache-1.2.3.jar
+ehcache.version=1.2.3
ehcache.name=EHCache cache
ehcache.when=runtime, optional (required if no other cache provider is set)
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/cache/EhCache.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/cache/EhCache.java 2006-11-03 16:23:21 UTC (rev 10715)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/cache/EhCache.java 2006-11-03 19:05:11 UTC (rev 10716)
@@ -124,6 +124,9 @@
catch (IllegalStateException e) {
throw new CacheException( e );
}
+ catch (net.sf.ehcache.CacheException e) {
+ throw new CacheException( e );
+ }
}
@@ -145,6 +148,9 @@
catch (IllegalStateException e) {
throw new CacheException( e );
}
+ catch (net.sf.ehcache.CacheException e) {
+ throw new CacheException( e );
+ }
}
/**
@@ -160,7 +166,7 @@
catch (IllegalStateException e) {
throw new CacheException( e );
}
- catch (IOException e) {
+ catch (net.sf.ehcache.CacheException e) {
throw new CacheException( e );
}
}
18 years, 2 months
Hibernate SVN: r10715 - trunk/Hibernate3/src/org/hibernate/jdbc
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-11-03 11:23:21 -0500 (Fri, 03 Nov 2006)
New Revision: 10715
Added:
trunk/Hibernate3/src/org/hibernate/jdbc/ConnectionWrapper.java
Modified:
trunk/Hibernate3/src/org/hibernate/jdbc/BorrowedConnectionProxy.java
Log:
HHH-1737 : ConnectionWrapper
Modified: trunk/Hibernate3/src/org/hibernate/jdbc/BorrowedConnectionProxy.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/jdbc/BorrowedConnectionProxy.java 2006-11-03 16:23:02 UTC (rev 10714)
+++ trunk/Hibernate3/src/org/hibernate/jdbc/BorrowedConnectionProxy.java 2006-11-03 16:23:21 UTC (rev 10715)
@@ -20,6 +20,8 @@
*/
public class BorrowedConnectionProxy implements InvocationHandler {
+ private static final Class[] PROXY_INTERFACES = new Class[] { Connection.class, ConnectionWrapper.class };
+
private final ConnectionManager connectionManager;
private boolean useable = true;
@@ -36,6 +38,11 @@
if ( !useable ) {
throw new HibernateException( "connnection proxy not usable after transaction completion" );
}
+
+ if ( "getWrappedConnection".equals( method.getName() ) ) {
+ return connectionManager.getConnection();
+ }
+
try {
return method.invoke( connectionManager.getConnection(), args );
}
@@ -48,7 +55,7 @@
BorrowedConnectionProxy handler = new BorrowedConnectionProxy( connectionManager );
return ( Connection ) Proxy.newProxyInstance(
Connection.class.getClassLoader(),
- new Class[] { Connection.class },
+ PROXY_INTERFACES,
handler
);
}
@@ -61,4 +68,14 @@
}
}
}
+
+ public static Connection getWrappedConnection(Connection connection) {
+ if ( connection == null ) {
+ return null;
+ }
+ if ( connection instanceof ConnectionWrapper ) {
+ ( ( ConnectionWrapper ) connection ).getWrappedConnection();
+ }
+ return connection;
+ }
}
Added: trunk/Hibernate3/src/org/hibernate/jdbc/ConnectionWrapper.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/jdbc/ConnectionWrapper.java 2006-11-03 16:23:02 UTC (rev 10714)
+++ trunk/Hibernate3/src/org/hibernate/jdbc/ConnectionWrapper.java 2006-11-03 16:23:21 UTC (rev 10715)
@@ -0,0 +1,18 @@
+package org.hibernate.jdbc;
+
+import java.sql.Connection;
+
+/**
+ * Interface implemented by JDBC connection wrappers in order to give
+ * access to the underlying wrapped connection.
+ *
+ * @author Steve Ebersole
+ */
+public interface ConnectionWrapper {
+ /**
+ * Get a reference to the wrapped connection.
+ *
+ * @return The wrapped connection.
+ */
+ public Connection getWrappedConnection();
+}
18 years, 2 months
Hibernate SVN: r10714 - branches/Branch_3_2/Hibernate3/src/org/hibernate/jdbc
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-11-03 11:23:02 -0500 (Fri, 03 Nov 2006)
New Revision: 10714
Added:
branches/Branch_3_2/Hibernate3/src/org/hibernate/jdbc/ConnectionWrapper.java
Modified:
branches/Branch_3_2/Hibernate3/src/org/hibernate/jdbc/BorrowedConnectionProxy.java
Log:
HHH-1737 : ConnectionWrapper
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/jdbc/BorrowedConnectionProxy.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/jdbc/BorrowedConnectionProxy.java 2006-11-03 16:20:54 UTC (rev 10713)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/jdbc/BorrowedConnectionProxy.java 2006-11-03 16:23:02 UTC (rev 10714)
@@ -20,6 +20,8 @@
*/
public class BorrowedConnectionProxy implements InvocationHandler {
+ private static final Class[] PROXY_INTERFACES = new Class[] { Connection.class, ConnectionWrapper.class };
+
private final ConnectionManager connectionManager;
private boolean useable = true;
@@ -36,6 +38,11 @@
if ( !useable ) {
throw new HibernateException( "connnection proxy not usable after transaction completion" );
}
+
+ if ( "getWrappedConnection".equals( method.getName() ) ) {
+ return connectionManager.getConnection();
+ }
+
try {
return method.invoke( connectionManager.getConnection(), args );
}
@@ -48,7 +55,7 @@
BorrowedConnectionProxy handler = new BorrowedConnectionProxy( connectionManager );
return ( Connection ) Proxy.newProxyInstance(
Connection.class.getClassLoader(),
- new Class[] { Connection.class },
+ PROXY_INTERFACES,
handler
);
}
@@ -61,4 +68,14 @@
}
}
}
+
+ public static Connection getWrappedConnection(Connection connection) {
+ if ( connection == null ) {
+ return null;
+ }
+ if ( connection instanceof ConnectionWrapper ) {
+ ( ( ConnectionWrapper ) connection ).getWrappedConnection();
+ }
+ return connection;
+ }
}
Added: branches/Branch_3_2/Hibernate3/src/org/hibernate/jdbc/ConnectionWrapper.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/jdbc/ConnectionWrapper.java 2006-11-03 16:20:54 UTC (rev 10713)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/jdbc/ConnectionWrapper.java 2006-11-03 16:23:02 UTC (rev 10714)
@@ -0,0 +1,18 @@
+package org.hibernate.jdbc;
+
+import java.sql.Connection;
+
+/**
+ * Interface implemented by JDBC connection wrappers in order to give
+ * access to the underlying wrapped connection.
+ *
+ * @author Steve Ebersole
+ */
+public interface ConnectionWrapper {
+ /**
+ * Get a reference to the wrapped connection.
+ *
+ * @return The wrapped connection.
+ */
+ public Connection getWrappedConnection();
+}
18 years, 2 months
Hibernate SVN: r10713 - in trunk/Hibernate3: src/org/hibernate/cfg src/org/hibernate/tool/hbm2ddl test/org/hibernate/test test/org/hibernate/test/tool
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-11-03 11:20:54 -0500 (Fri, 03 Nov 2006)
New Revision: 10713
Added:
trunk/Hibernate3/test/org/hibernate/test/tool/
trunk/Hibernate3/test/org/hibernate/test/tool/Team.hbm.xml
trunk/Hibernate3/test/org/hibernate/test/tool/Team.java
trunk/Hibernate3/test/org/hibernate/test/tool/TestSchemaTools.java
Modified:
trunk/Hibernate3/src/org/hibernate/cfg/Configuration.java
trunk/Hibernate3/src/org/hibernate/tool/hbm2ddl/DatabaseMetadata.java
trunk/Hibernate3/src/org/hibernate/tool/hbm2ddl/TableMetadata.java
Log:
merged HHH-1629 and HHH-2208 from 3.2
Modified: trunk/Hibernate3/src/org/hibernate/cfg/Configuration.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/cfg/Configuration.java 2006-11-03 15:38:01 UTC (rev 10712)
+++ trunk/Hibernate3/src/org/hibernate/cfg/Configuration.java 2006-11-03 16:20:54 UTC (rev 10713)
@@ -916,11 +916,13 @@
while ( iter.hasNext() ) {
Table table = (Table) iter.next();
if ( table.isPhysicalTable() ) {
-
+ Settings settings = buildSettings();
TableMetadata tableInfo = databaseMetadata.getTableMetadata(
table.getName(),
- table.getSchema(),
- table.getCatalog()
+ ( table.getSchema() == null ) ? settings.getDefaultSchemaName() : table.getSchema(),
+ ( table.getCatalog() == null ) ? settings.getDefaultCatalogName() : table.getCatalog(),
+ table.isQuoted()
+
);
if ( tableInfo == null ) {
script.add(
@@ -961,7 +963,8 @@
TableMetadata tableInfo = databaseMetadata.getTableMetadata(
table.getName(),
table.getSchema(),
- table.getCatalog()
+ table.getCatalog(),
+ table.isQuoted()
);
if ( dialect.hasAlterTable() ) {
@@ -1035,13 +1038,13 @@
while ( iter.hasNext() ) {
Table table = (Table) iter.next();
if ( table.isPhysicalTable() ) {
+ Settings settings = buildSettings();
TableMetadata tableInfo = databaseMetadata.getTableMetadata(
table.getName(),
- table.getSchema(),
- table.getCatalog()
- );
-
+ ( table.getSchema() == null ) ? settings.getDefaultSchemaName() : table.getSchema(),
+ ( table.getCatalog() == null ) ? settings.getDefaultCatalogName() : table.getCatalog(),
+ table.isQuoted());
if ( tableInfo == null ) {
throw new HibernateException( "Missing table: " + table.getName() );
}
Modified: trunk/Hibernate3/src/org/hibernate/tool/hbm2ddl/DatabaseMetadata.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/tool/hbm2ddl/DatabaseMetadata.java 2006-11-03 15:38:01 UTC (rev 10712)
+++ trunk/Hibernate3/src/org/hibernate/tool/hbm2ddl/DatabaseMetadata.java 2006-11-03 16:20:54 UTC (rev 10713)
@@ -16,6 +16,7 @@
import org.hibernate.HibernateException;
import org.hibernate.exception.JDBCExceptionHelper;
import org.hibernate.exception.SQLExceptionConverter;
+import org.hibernate.mapping.Table;
import org.hibernate.dialect.Dialect;
import org.hibernate.util.StringHelper;
@@ -47,9 +48,10 @@
private static final String[] TYPES = {"TABLE"};
- public TableMetadata getTableMetadata(String name, String schema, String catalog) throws HibernateException {
+ public TableMetadata getTableMetadata(String name, String schema, String catalog, boolean isQuoted) throws HibernateException {
- TableMetadata table = (TableMetadata) tables.get(name);
+ Object identifier = identifier(catalog, schema, name);
+ TableMetadata table = (TableMetadata) tables.get(identifier);
if (table!=null) {
return table;
}
@@ -59,7 +61,8 @@
ResultSet rs = null;
try {
- if ( meta.storesUpperCaseIdentifiers() ) {
+ if ( (isQuoted && meta.storesUpperCaseQuotedIdentifiers())
+ || (!isQuoted && meta.storesUpperCaseIdentifiers() )) {
rs = meta.getTables(
StringHelper.toUpperCase(catalog),
StringHelper.toUpperCase(schema),
@@ -67,7 +70,8 @@
TYPES
);
}
- else if ( meta.storesLowerCaseIdentifiers() ) {
+ else if ( (isQuoted && meta.storesLowerCaseQuotedIdentifiers())
+ || (!isQuoted && meta.storesLowerCaseIdentifiers() )) {
rs = meta.getTables(
StringHelper.toLowerCase(catalog),
StringHelper.toLowerCase(schema),
@@ -83,7 +87,7 @@
String tableName = rs.getString("TABLE_NAME");
if ( name.equalsIgnoreCase(tableName) ) {
table = new TableMetadata(rs, meta, extras);
- tables.put(name, table);
+ tables.put(identifier, table);
return table;
}
}
@@ -107,6 +111,10 @@
}
+ private Object identifier(String catalog, String schema, String name) {
+ return Table.qualify(catalog,schema,name);
+ }
+
private void initSequences(Connection connection, Dialect dialect) throws SQLException {
if ( dialect.supportsSequences() ) {
String sql = dialect.getQuerySequencesString();
@@ -132,25 +140,35 @@
}
public boolean isSequence(Object key) {
- return key instanceof String && sequences.contains( ( (String) key ).toLowerCase() );
- }
-
- public boolean isTable(Object key) throws HibernateException {
- if(key instanceof String) {
- if ( getTableMetadata( (String) key, null, null ) != null ) {
- return true;
- } else {
- String[] strings = StringHelper.split(".", (String) key);
- if(strings.length==3) {
- return getTableMetadata(strings[2], strings[1], strings[0]) != null;
- } else if (strings.length==2) {
- return getTableMetadata(strings[1], strings[0], null) != null;
- }
- }
+ if (key instanceof String){
+ String[] strings = StringHelper.split(".", (String) key);
+ return sequences.contains( strings[strings.length-1].toLowerCase());
}
return false;
}
-
+
+ public boolean isTable(Object key) throws HibernateException {
+ if(key instanceof String) {
+ Table tbl = new Table((String)key);
+ if ( getTableMetadata( tbl.getName(), tbl.getSchema(), tbl.getCatalog(), tbl.isQuoted() ) != null ) {
+ return true;
+ } else {
+ String[] strings = StringHelper.split(".", (String) key);
+ if(strings.length==3) {
+ tbl = new Table(strings[2]);
+ tbl.setCatalog(strings[0]);
+ tbl.setSchema(strings[1]);
+ return getTableMetadata( tbl.getName(), tbl.getSchema(), tbl.getCatalog(), tbl.isQuoted() ) != null;
+ } else if (strings.length==2) {
+ tbl = new Table(strings[1]);
+ tbl.setSchema(strings[0]);
+ return getTableMetadata( tbl.getName(), tbl.getSchema(), tbl.getCatalog(), tbl.isQuoted() ) != null;
+ }
+ }
+ }
+ return false;
+ }
+
public String toString() {
return "DatabaseMetadata" + tables.keySet().toString() + sequences.toString();
}
Modified: trunk/Hibernate3/src/org/hibernate/tool/hbm2ddl/TableMetadata.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/tool/hbm2ddl/TableMetadata.java 2006-11-03 15:38:01 UTC (rev 10712)
+++ trunk/Hibernate3/src/org/hibernate/tool/hbm2ddl/TableMetadata.java 2006-11-03 16:20:54 UTC (rev 10713)
@@ -9,11 +9,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.util.StringHelper;
/**
* JDBC table metadata
- * @author Christoph Sturm
+ * @author Christoph Sturm, Max Rydahl Andersen
*/
public class TableMetadata {
@@ -108,24 +107,7 @@
ResultSet rs = null;
try {
- if ( meta.storesUpperCaseIdentifiers() ) {
- rs = meta.getImportedKeys(
- StringHelper.toUpperCase(catalog),
- StringHelper.toUpperCase(schema),
- StringHelper.toUpperCase(name)
- );
- }
- else if ( meta.storesLowerCaseIdentifiers() ) {
- rs = meta.getImportedKeys(
- StringHelper.toLowerCase(catalog),
- StringHelper.toLowerCase(schema),
- StringHelper.toLowerCase(name)
- );
- }
- else {
- rs = meta.getImportedKeys(catalog, schema, name);
- }
-
+ rs = meta.getImportedKeys(catalog, schema, name);
while ( rs.next() ) addForeignKey(rs);
}
finally {
@@ -137,28 +119,8 @@
ResultSet rs = null;
try {
- if ( meta.storesUpperCaseIdentifiers() ) {
- rs = meta.getIndexInfo(
- StringHelper.toUpperCase(catalog),
- StringHelper.toUpperCase(schema),
- StringHelper.toUpperCase(name),
- false,
- true
- );
- }
- else if ( meta.storesLowerCaseIdentifiers() ) {
- rs = meta.getIndexInfo(
- StringHelper.toLowerCase(catalog),
- StringHelper.toLowerCase(schema),
- StringHelper.toLowerCase(name),
- false,
- true
- );
- }
- else {
- rs = meta.getIndexInfo(catalog, schema, name, false, true);
- }
-
+ rs = meta.getIndexInfo(catalog, schema, name, false, true);
+
while ( rs.next() ) {
if ( rs.getShort("TYPE") == DatabaseMetaData.tableIndexStatistic ) continue;
addIndex(rs);
@@ -173,26 +135,7 @@
ResultSet rs = null;
try {
- if ( meta.storesUpperCaseIdentifiers() ) {
- rs = meta.getColumns(
- StringHelper.toUpperCase(catalog),
- StringHelper.toUpperCase(schema),
- StringHelper.toUpperCase(name),
- "%"
- );
- }
- else if ( meta.storesLowerCaseIdentifiers() ) {
- rs = meta.getColumns(
- StringHelper.toLowerCase(catalog),
- StringHelper.toLowerCase(schema),
- StringHelper.toLowerCase(name),
- "%"
- );
- }
- else {
- rs = meta.getColumns(catalog, schema, name, "%");
- }
-
+ rs = meta.getColumns(catalog, schema, name, "%");
while ( rs.next() ) addColumn(rs);
}
finally {
Added: trunk/Hibernate3/test/org/hibernate/test/tool/Team.hbm.xml
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/tool/Team.hbm.xml 2006-11-03 15:38:01 UTC (rev 10712)
+++ trunk/Hibernate3/test/org/hibernate/test/tool/Team.hbm.xml 2006-11-03 16:20:54 UTC (rev 10713)
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping SYSTEM
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.hibernate.test.tool">
+ <class name="Team" table="`Team`">
+ <id name="id" column="`iD`">
+ <generator class="native">
+ <param name="sequence">TEAM_SEQ</param>
+ </generator>
+ </id>
+ <property name="name"/>
+ </class>
+
+ <class entity-name="OtherTeam" name="Team" table="TEAM">
+ <id name="id" column="id">
+ <generator class="native">
+ <param name="sequence">TEAM_SEQ</param>
+ </generator>
+ </id>
+ <property name="name" column="xname"/>
+ </class>
+
+</hibernate-mapping>
Added: trunk/Hibernate3/test/org/hibernate/test/tool/Team.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/tool/Team.java 2006-11-03 15:38:01 UTC (rev 10712)
+++ trunk/Hibernate3/test/org/hibernate/test/tool/Team.java 2006-11-03 16:20:54 UTC (rev 10713)
@@ -0,0 +1,20 @@
+package org.hibernate.test.tool;
+
+
+public class Team {
+ private Long id;
+ private String name;
+ public Long getId() {
+ return id;
+ }
+ public void setId(Long id) {
+ this.id = id;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+
+}
Added: trunk/Hibernate3/test/org/hibernate/test/tool/TestSchemaTools.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/tool/TestSchemaTools.java 2006-11-03 15:38:01 UTC (rev 10712)
+++ trunk/Hibernate3/test/org/hibernate/test/tool/TestSchemaTools.java 2006-11-03 16:20:54 UTC (rev 10713)
@@ -0,0 +1,209 @@
+package org.hibernate.test.tool;
+
+import java.sql.Connection;
+import java.sql.Statement;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+import org.hibernate.HibernateException;
+import org.hibernate.Session;
+import org.hibernate.test.TestCase;
+import org.hibernate.tool.hbm2ddl.SchemaExport;
+import org.hibernate.tool.hbm2ddl.SchemaUpdate;
+import org.hibernate.tool.hbm2ddl.SchemaValidator;
+
+/**
+ * @author Anthony
+ *
+ * Basic smoke test for schemaupdate/validator.
+ * Dependent on schemas, and probably also HQLDB - Not possible to have in the global test suite at the moment.
+ *
+ * WARNING, if you want this test to work, you need to define a default schema = SB
+ * in hibernate global configuration.
+ * This schema should not be the same at the default db user schema and should come after the users schema alphabetically.
+ *
+ */
+public class TestSchemaTools extends TestCase{
+
+ public void testSchemaTools() throws Exception{
+ // database schema have been created thanks to the setUp method
+ // we have 2 schemas SA et SB, SB must be set as the default schema
+ // used by hibernate hibernate.default_schema SB
+ SchemaExport se = new SchemaExport(getCfg());
+ se.create(true,true);
+
+ // here we modify the generated table in order to test SchemaUpdate
+ Session session = openSession();
+ Connection conn = session.connection();
+ Statement stat = conn.createStatement();
+ stat.execute("ALTER TABLE \"SB\".\"Team\" DROP COLUMN name ");
+
+ // update schema
+ SchemaUpdate su = new SchemaUpdate(getCfg());
+ su.execute(true,true);
+
+ // we can run schema validation. Note that in the setUp method a *wrong* table
+ // has been created with different column names
+ // if schema validator chooses the bad db schema, then the testcase will fail (exception)
+ SchemaValidator sv = new SchemaValidator(getCfg());
+ sv.validate();
+
+ // it's time to clean our database
+ se.drop(true,true);
+
+ // then the schemas and false table.
+
+ stat.execute("DROP TABLE \"SA\".\"Team\" ");
+ stat.execute(" DROP SCHEMA sa ");
+ stat.execute("DROP SCHEMA sb ");
+ stat.close();
+ session.close();
+ }
+
+ public void testSchemaToolsNonQuote() throws Exception{
+ // database schema have been created thanks to the setUp method
+ // we have 2 schemas SA et SB, SB must be set as the default schema
+ // used by hibernate hibernate.default_schema SB
+ SchemaExport se = new SchemaExport(getCfg());
+ se.create(true,true);
+
+ // here we modify the generated table in order to test SchemaUpdate
+ Session session = openSession();
+ Connection conn = session.connection();
+ Statement stat = conn.createStatement();
+ stat.execute("ALTER TABLE \"SB\".\"TEAM\" DROP COLUMN xname ");
+
+ // update schema
+ SchemaUpdate su = new SchemaUpdate(getCfg());
+ su.execute(true,true);
+
+ // we can run schema validation. Note that in the setUp method a *wrong* table
+ // has been created with different column names
+ // if schema validator chooses the bad db schema, then the testcase will fail (exception)
+ SchemaValidator sv = new SchemaValidator(getCfg());
+ sv.validate();
+
+ // it's time to clean our database
+ se.drop(true,true);
+
+ // then the schemas and false table.
+
+ stat.execute("DROP TABLE \"SA\".\"Team\" ");
+ stat.execute(" DROP SCHEMA sa ");
+ stat.execute("DROP SCHEMA sb ");
+ stat.close();
+ session.close();
+ }
+ public void testFailingQuoteValidation() throws Exception{
+ // database schema have been created thanks to the setUp method
+ // we have 2 schemas SA et SB, SB must be set as the default schema
+ // used by hibernate hibernate.default_schema SB
+ SchemaExport se = new SchemaExport(getCfg());
+ se.create(true,true);
+
+ // here we modify the generated table in order to test SchemaUpdate
+ Session session = openSession();
+ Connection conn = session.connection();
+ Statement stat = conn.createStatement();
+ stat.execute("ALTER TABLE \"SB\".\"Team\" DROP COLUMN name ");
+
+ // update schema
+ //SchemaUpdate su = new SchemaUpdate(getCfg());
+ //su.execute(true,true);
+
+ try {
+ SchemaValidator sv = new SchemaValidator(getCfg());
+ sv.validate();
+ fail("should fail since we mutated the current schema.");
+ } catch(HibernateException he) {
+
+ }
+
+ // it's time to clean our database
+ se.drop(true,true);
+
+ // then the schemas and false table.
+
+ stat.execute("DROP TABLE \"SA\".\"Team\" ");
+ stat.execute(" DROP SCHEMA sa ");
+ stat.execute("DROP SCHEMA sb ");
+ stat.close();
+ session.close();
+ }
+
+ public void testFailingNonQuoteValidation() throws Exception{
+ // database schema have been created thanks to the setUp method
+ // we have 2 schemas SA et SB, SB must be set as the default schema
+ // used by hibernate hibernate.default_schema SB
+ SchemaExport se = new SchemaExport(getCfg());
+ se.create(true,true);
+
+ // here we modify the generated table in order to test SchemaUpdate
+ Session session = openSession();
+ Connection conn = session.connection();
+ Statement stat = conn.createStatement();
+ stat.execute("ALTER TABLE \"SB\".\"TEAM\" DROP COLUMN xname ");
+
+ // update schema
+ //SchemaUpdate su = new SchemaUpdate(getCfg());
+ //su.execute(true,true);
+
+ try {
+ SchemaValidator sv = new SchemaValidator(getCfg());
+ sv.validate();
+ fail("should fail since we mutated the current schema.");
+ } catch(HibernateException he) {
+
+ }
+
+ // it's time to clean our database
+ se.drop(true,true);
+
+ // then the schemas and false table.
+
+ stat.execute("DROP TABLE \"SA\".\"Team\" ");
+ stat.execute(" DROP SCHEMA sa ");
+ stat.execute("DROP SCHEMA sb ");
+ stat.close();
+ session.close();
+ }
+
+ public TestSchemaTools(String arg0) {
+ super(arg0);
+ }
+
+ public String[] getMappings() {
+ return new String[] {"tool/Team.hbm.xml"};
+ }
+
+ public static Test suite() {
+ return new TestSuite(TestSchemaTools.class);
+ }
+
+ public static void main(String[] args) throws Exception {
+ TestRunner.run( suite() );
+ }
+
+ protected boolean recreateSchema() {
+ return false;
+ }
+
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ Session session = openSession();
+ Connection conn = session.connection();
+ Statement stat = conn.createStatement();
+ stat.execute("CREATE SCHEMA sb AUTHORIZATION DBA ");
+ stat.execute(" CREATE SCHEMA sa AUTHORIZATION DBA ");
+ stat.execute(" CREATE TABLE \"SA\".\"Team\" (test INTEGER) ");
+ stat.close();
+ conn.close();
+
+ }
+
+
+
+}
18 years, 2 months
Hibernate SVN: r10712 - in trunk/Hibernate3/test/org/hibernate/test: . cfg
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-11-03 10:38:01 -0500 (Fri, 03 Nov 2006)
New Revision: 10712
Added:
trunk/Hibernate3/test/org/hibernate/test/cfg/
trunk/Hibernate3/test/org/hibernate/test/cfg/Cacheable.hbm.xml
trunk/Hibernate3/test/org/hibernate/test/cfg/CacheableFileTest.java
Log:
HHH-2108 : fixed cacheable files
Added: trunk/Hibernate3/test/org/hibernate/test/cfg/Cacheable.hbm.xml
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/cfg/Cacheable.hbm.xml 2006-11-03 15:37:47 UTC (rev 10711)
+++ trunk/Hibernate3/test/org/hibernate/test/cfg/Cacheable.hbm.xml 2006-11-03 15:38:01 UTC (rev 10712)
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping>
+
+ <class entity-name="Entity">
+ <id name="id" type="long" column="ID">
+ <generator class="increment"/>
+ </id>
+ <property name="name" type="string" column="NAME"/>
+ </class>
+
+</hibernate-mapping>
Added: trunk/Hibernate3/test/org/hibernate/test/cfg/CacheableFileTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/cfg/CacheableFileTest.java 2006-11-03 15:37:47 UTC (rev 10711)
+++ trunk/Hibernate3/test/org/hibernate/test/cfg/CacheableFileTest.java 2006-11-03 15:38:01 UTC (rev 10712)
@@ -0,0 +1,41 @@
+package org.hibernate.test.cfg;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+import org.hibernate.cfg.Configuration;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class CacheableFileTest extends TestCase {
+
+ public static final String MAPPING = "org/hibernate/test/cfg/Cacheable.hbm.xml";
+
+ private File mappingFile;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ mappingFile = new File( getClass().getClassLoader().getResource( MAPPING ).getFile() );
+ assertTrue( mappingFile.exists() );
+ File cached = new File( mappingFile.getParentFile(), mappingFile.getName() + ".bin" );
+ if ( cached.exists() ) {
+ cached.delete();
+ }
+ }
+
+ protected void tearDown() throws Exception {
+ mappingFile = null;
+ super.tearDown();
+ }
+
+ public void testCachedFiles() {
+ Configuration cfg = new Configuration();
+ cfg.addCacheableFile( mappingFile );
+ Configuration cfg2 = new Configuration();
+ cfg2.addCacheableFile( mappingFile );
+ }
+}
18 years, 2 months