[hibernate-commits] Hibernate SVN: r10718 - in branches/Branch_3_2/Hibernate3: etc src/org/hibernate/dialect test/org/hibernate/test test/org/hibernate/test/bidi

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Mon Nov 6 06:15:50 EST 2006


Author: max.andersen at 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" 




More information about the hibernate-commits mailing list