You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by mt...@apache.org on 2010/02/08 20:22:13 UTC
svn commit: r907763 - in /openjpa/branches/1.3.x:
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/...
Author: mtylenda
Date: Mon Feb 8 19:22:13 2010
New Revision: 907763
URL: http://svn.apache.org/viewvc?rev=907763&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/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/H2Dictionary.java
openjpa/branches/1.3.x/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/sql-error-state-codes.xml
openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/generationtype/TestMultipleSchemaNames.java
openjpa/branches/1.3.x/openjpa-project/src/doc/manual/supported_databases.xml
Modified: openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/H2Dictionary.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/H2Dictionary.java?rev=907763&r1=907762&r2=907763&view=diff
==============================================================================
--- openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/H2Dictionary.java (original)
+++ openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/H2Dictionary.java Mon Feb 8 19:22:13 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;
@@ -36,7 +34,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
*/
@@ -53,30 +51,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",
@@ -99,7 +86,9 @@
}
public int getPreferredType(int type) {
- return super.getPreferredType(type);
+ if(type == Types.BIT)
+ return Types.BOOLEAN;
+ return type;
}
public String[] getAddPrimaryKeySQL(PrimaryKey pk) {
@@ -188,8 +177,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);
+ }
}
public void indexOf(SQLBuffer buf, FilterValue str, FilterValue find,
Modified: openjpa/branches/1.3.x/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/sql-error-state-codes.xml
URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/sql-error-state-codes.xml?rev=907763&r1=907762&r2=907763&view=diff
==============================================================================
--- openjpa/branches/1.3.x/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/sql-error-state-codes.xml (original)
+++ openjpa/branches/1.3.x/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/sql-error-state-codes.xml Mon Feb 8 19:22:13 2010
@@ -91,7 +91,11 @@
</dictionary>
<dictionary class="org.apache.openjpa.jdbc.sql.H2Dictionary">
- <referential-integrity>22003,22012,22025,23000,23001</referential-integrity>
+ <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>
</dictionary>
<dictionary class="org.apache.openjpa.jdbc.sql.HSQLDictionary">
Modified: openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/generationtype/TestMultipleSchemaNames.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/generationtype/TestMultipleSchemaNames.java?rev=907763&r1=907762&r2=907763&view=diff
==============================================================================
--- openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/generationtype/TestMultipleSchemaNames.java (original)
+++ openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/generationtype/TestMultipleSchemaNames.java Mon Feb 8 19:22:13 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.PostgresDictionary;
import org.apache.openjpa.persistence.OpenJPAEntityManager;
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
@@ -398,7 +399,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 and MySQL also don't create schemas automatically but
* we give up as they treat schemas in special ways.
@@ -409,7 +410,7 @@
DBDictionary dict = ((JDBCConfiguration) em.getConfiguration())
.getDBDictionaryInstance();
- if (!(dict instanceof PostgresDictionary)) {
+ if (!(dict instanceof PostgresDictionary || dict instanceof H2Dictionary)) {
closeEMF(emf);
return;
}
Modified: openjpa/branches/1.3.x/openjpa-project/src/doc/manual/supported_databases.xml
URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-project/src/doc/manual/supported_databases.xml?rev=907763&r1=907762&r2=907763&view=diff
==============================================================================
--- openjpa/branches/1.3.x/openjpa-project/src/doc/manual/supported_databases.xml (original)
+++ openjpa/branches/1.3.x/openjpa-project/src/doc/manual/supported_databases.xml Mon Feb 8 19:22:13 2010
@@ -523,7 +523,7 @@
<itemizedlist>
<listitem>
<para>
-H2 does not support cross joins
+None
</para>
</listitem>
</itemizedlist>