[hibernate-commits] Hibernate SVN: r20268 - core/trunk/core/src/main/java/org/hibernate/dialect.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Thu Aug 26 14:53:07 EDT 2010


Author: steve.ebersole at jboss.com
Date: 2010-08-26 14:53:07 -0400 (Thu, 26 Aug 2010)
New Revision: 20268

Modified:
   core/trunk/core/src/main/java/org/hibernate/dialect/DerbyDialect.java
Log:
HHH-5427 - derby 10.6.1.0 native sequence support broken


Modified: core/trunk/core/src/main/java/org/hibernate/dialect/DerbyDialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/DerbyDialect.java	2010-08-26 17:53:24 UTC (rev 20267)
+++ core/trunk/core/src/main/java/org/hibernate/dialect/DerbyDialect.java	2010-08-26 18:53:07 UTC (rev 20268)
@@ -29,9 +29,9 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.hibernate.MappingException;
 import org.hibernate.dialect.function.AnsiTrimFunction;
 import org.hibernate.dialect.function.DerbyConcatFunction;
-import org.hibernate.id.TableHiLoGenerator;
 import org.hibernate.sql.CaseFragment;
 import org.hibernate.sql.DerbyCaseFragment;
 import org.hibernate.util.ReflectHelper;
@@ -57,7 +57,8 @@
 		determineDriverVersion();
 	}
 
-	/*package*/ void determineDriverVersion() {
+	@SuppressWarnings({ "UnnecessaryUnboxing" })
+	private void determineDriverVersion() {
 		try {
 			// locate the derby sysinfo class and query its version info
 			final Class sysinfoClass = ReflectHelper.classForName( "org.apache.derby.tools.sysinfo", this.getClass() );
@@ -73,7 +74,7 @@
 		}
 	}
 
-	/*package*/ boolean isTenPointFiveReleaseOrNewer() {
+	private boolean isTenPointFiveReleaseOrNewer() {
 		return driverVersionMajor > 10 || ( driverVersionMajor == 10 && driverVersionMinor >= 5 );
 	}
 
@@ -81,13 +82,6 @@
 		return ", ";
 	}
 
-//	/**
-//	 * This is different in Cloudscape to DB2.
-//	 */
-//	public String getIdentityColumnString() {
-//		return "not null generated always as identity"; //$NON-NLS-1
-//	}
-
 	/**
 	 * Return the case statement modified for Cloudscape.
 	 */
@@ -99,14 +93,30 @@
 	      return true;
 	}
 
-//	public Class getNativeIdentifierGeneratorClass() {
-//		return TableHiLoGenerator.class;
-//	}
-
 	public boolean supportsSequences() {
-		return false;
+		// technically sequence support was added in 10.6.1.0...
+		//
+		// The problem though is that I am not exactly sure how to differentiate 10.6.1.0 from any other 10.6.x release.
+		//
+		// http://db.apache.org/derby/docs/10.0/publishedapi/org/apache/derby/tools/sysinfo.html seems incorrect.  It
+		// states that derby's versioning scheme is major.minor.maintenance, but obviously 10.6.1.0 has 4 components
+		// to it, not 3.
+		//
+		// Let alone the fact that it states that versions with the matching major.minor are 'feature
+		// compatible' which is clearly not the case here (sequence support is a new feature...)
+		return driverVersionMajor > 10 || ( driverVersionMajor == 10 && driverVersionMinor >= 6 );
 	}
 
+	@Override
+	public String getSequenceNextValString(String sequenceName) {
+		if ( supportsSequences() ) {
+			return "values next value for " + sequenceName;
+		}
+		else {
+			throw new MappingException( "Derby does not support sequence prior to release 10.6.1.0" );
+		}
+	}
+
 	public boolean supportsLimit() {
 		return isTenPointFiveReleaseOrNewer();
 	}



More information about the hibernate-commits mailing list