openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mtyle...@apache.org
Subject svn commit: r905001 - in /openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/ openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/generationtype/ openjpa-...
Date Sun, 31 Jan 2010 11:15:01 GMT
Author: mtylenda
Date: Sun Jan 31 11:15:01 2010
New Revision: 905001

URL: http://svn.apache.org/viewvc?rev=905001&view=rev
Log:
OPENJPA-1367: Improvements for H2 database. Commit patch provided by Prashant Bhat with slight
modifications. Information on CROSS JOIN provided by Thomas Mueller.

Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/H2Dictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/sql-error-state-codes.xml
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/generationtype/TestMultipleSchemaNames.java
    openjpa/trunk/openjpa-project/src/doc/manual/supported_databases.xml

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/H2Dictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/H2Dictionary.java?rev=905001&r1=905000&r2=905001&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/H2Dictionary.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/H2Dictionary.java
Sun Jan 31 11:15:01 2010
@@ -18,10 +18,8 @@
  */
 package org.apache.openjpa.jdbc.sql;
 
-import java.math.BigDecimal;
 import java.sql.Connection;
 import java.sql.DatabaseMetaData;
-import java.sql.PreparedStatement;
 import java.sql.SQLException;
 import java.sql.Types;
 import java.util.Arrays;
@@ -37,7 +35,7 @@
 import org.apache.openjpa.meta.JavaTypes;
 
 /**
- * Support for the H2 database ({@link http://www.h2database.com}).
+ * Dictionary for H2 ({@link http://www.h2database.com}).
  *
  * @since 0.9.7
  */
@@ -54,30 +52,19 @@
         autoAssignTypeName = "INTEGER";
         nextSequenceQuery = "CALL NEXT VALUE FOR {0}";
 
-        // CROSS JOIN is currently not supported
-        crossJoinClause = "JOIN";
-        requiresConditionForCrossJoin = true;
         stringLengthFunction = "LENGTH({0})";
         trimLeadingFunction = "LTRIM({0})";
         trimTrailingFunction = "RTRIM({0})";
         trimBothFunction = "TRIM({0})";
 
-        useSchemaName = true;
-        supportsSelectForUpdate = true;
         supportsSelectStartIndex = true;
         supportsSelectEndIndex = true;
         rangePosition = RANGE_POST_LOCK;
         supportsDeferredConstraints = false;
 
-        blobTypeName = "BLOB";
-        doubleTypeName = "DOUBLE";
-
         supportsNullTableForGetPrimaryKeys = true;
         supportsNullTableForGetIndexInfo = true;
 
-        requiresCastForMathFunctions = false;
-        requiresCastForComparisons = false;
-
         reservedWordSet.addAll(Arrays.asList(new String[] {
             "CURRENT_TIMESTAMP", "CURRENT_TIME", "CURRENT_DATE", "CROSS",
             "DISTINCT", "EXCEPT", "EXISTS", "FROM", "FOR", "FALSE", "FULL",
@@ -102,7 +89,9 @@
 
     @Override
     public int getPreferredType(int type) {
-        return super.getPreferredType(type);
+        if(type == Types.BIT)
+            return Types.BOOLEAN;
+        return type;
     }
 
     @Override
@@ -219,8 +208,11 @@
         boolean subselect) {
         if (end != Long.MAX_VALUE)
             buf.append(" LIMIT ").appendValue(end - start);
-        if (start != 0)
+        if (start != 0) {
+            if(end == Long.MAX_VALUE)
+                buf.append(" LIMIT 0");
             buf.append(" OFFSET ").appendValue(start);
+        }
     }
 
     @Override

Modified: openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/sql-error-state-codes.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/sql-error-state-codes.xml?rev=905001&r1=905000&r2=905001&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/sql-error-state-codes.xml
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/sql-error-state-codes.xml
Sun Jan 31 11:15:01 2010
@@ -101,12 +101,12 @@
 	</dictionary>
 	
 	<dictionary class="org.apache.openjpa.jdbc.sql.H2Dictionary">
-		<lock></lock>
-		<referential-integrity>22003,22012,22025,23000,23001</referential-integrity>
-		<object-exists></object-exists>
-		<object-not-found></object-not-found>
+		<lock>HYT00</lock>
+		<referential-integrity>22003,22012,22025,23000,23002,23003</referential-integrity>
+		<object-exists>23001</object-exists>
+		<object-not-found>02000</object-not-found>
 		<optimistic></optimistic>
-		<query></query>
+		<query>90031</query>
 	</dictionary>
 	
 	<dictionary class="org.apache.openjpa.jdbc.sql.HSQLDictionary">

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/generationtype/TestMultipleSchemaNames.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/generationtype/TestMultipleSchemaNames.java?rev=905001&r1=905000&r2=905001&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/generationtype/TestMultipleSchemaNames.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/generationtype/TestMultipleSchemaNames.java
Sun Jan 31 11:15:01 2010
@@ -26,6 +26,7 @@
 
 import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
 import org.apache.openjpa.jdbc.sql.DBDictionary;
+import org.apache.openjpa.jdbc.sql.H2Dictionary;
 import org.apache.openjpa.jdbc.sql.MySQLDictionary;
 import org.apache.openjpa.jdbc.sql.OracleDictionary;
 import org.apache.openjpa.jdbc.sql.PostgresDictionary;
@@ -411,7 +412,7 @@
     }
 
     /**
-     * Create necessary schemas if running on PostgreSQL as it does
+     * Create necessary schemas if running on PostgreSQL or H2 as they do
      * not create them automatically.
      * Oracle, MySQL and MSSQL also don't create schemas automatically but
      * we give up as they treat schemas in special ways.
@@ -420,7 +421,7 @@
         OpenJPAEntityManagerFactorySPI tempEmf = createEMF();
         DBDictionary dict = ((JDBCConfiguration) tempEmf.getConfiguration()).getDBDictionaryInstance();
         
-        if (!(dict instanceof PostgresDictionary)) {
+        if (!(dict instanceof PostgresDictionary || dict instanceof H2Dictionary)) {
             closeEMF(tempEmf);
             return;
         }

Modified: openjpa/trunk/openjpa-project/src/doc/manual/supported_databases.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-project/src/doc/manual/supported_databases.xml?rev=905001&r1=905000&r2=905001&view=diff
==============================================================================
--- openjpa/trunk/openjpa-project/src/doc/manual/supported_databases.xml (original)
+++ openjpa/trunk/openjpa-project/src/doc/manual/supported_databases.xml Sun Jan 31 11:15:01
2010
@@ -678,7 +678,7 @@
             <itemizedlist>
                 <listitem>
                     <para>
-H2 does not support cross joins
+None
                     </para>
                 </listitem>
             </itemizedlist>



Mime
View raw message