You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by al...@apache.org on 2009/04/05 23:29:44 UTC
svn commit: r762161 [1/7] - in /openjpa/trunk:
openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/
openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/
openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/kernel/
openjpa-kernel/src/main/ja...
Author: allee8285
Date: Sun Apr 5 21:29:42 2009
New Revision: 762161
URL: http://svn.apache.org/viewvc?rev=762161&view=rev
Log:
OPENJPA-957 - Create Fetch*HintHandler(s) for property processing in EntityManager/Query interface methods.
Added:
openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractHintHandler.java (with props)
openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationHintHandler.java (with props)
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/TestEmLockMode.java (with props)
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/TestEmLockTimeout.java (with props)
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/TestFetchHints.java (with props)
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/TestMixedLockManagerFindBasic.java (with props)
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/TestMixedLockManagerFindException.java (with props)
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/TestMixedLockManagerFindPermutation.java (with props)
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/TestMixedLockManagerLockBasic.java (with props)
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/TestMixedLockManagerLockException.java (with props)
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/TestMixedLockManagerLockPermutation.java (with props)
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/TestMixedLockManagerRefreshBasic.java (with props)
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/TestMixedLockManagerRefreshException.java (with props)
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/TestMixedLockManagerRefreshPermutation.java (with props)
openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchPlanHintHandler.java (with props)
Removed:
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerFindBasicTest.java
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerFindExceptionTest.java
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerFindPermutationTest.java
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerLockBasicTest.java
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerLockExceptionTest.java
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerLockPermutationTest.java
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerRefreshBasicTest.java
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerRefreshExceptionTest.java
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerRefreshPermutationTest.java
Modified:
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCFetchConfigurationImpl.java
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/kernel/localizer.properties
openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingFetchConfiguration.java
openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfiguration.java
openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java
openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/kernel/localizer.properties
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/SequencedActionsTest.java
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestQueryTimeout.java
openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java
openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchPlan.java
openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchPlanImpl.java
openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/HintHandler.java
openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/MixedLockLevelsHelper.java
openjpa/trunk/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/localizer.properties
openjpa/trunk/openjpa-project/src/doc/manual/jpa_overview_query.xml
openjpa/trunk/openjpa-project/src/doc/manual/ref_guide_conf.xml
Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCFetchConfigurationImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCFetchConfigurationImpl.java?rev=762161&r1=762160&r2=762161&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCFetchConfigurationImpl.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCFetchConfigurationImpl.java Sun Apr 5 21:29:42 2009
@@ -19,8 +19,8 @@
package org.apache.openjpa.jdbc.kernel;
import java.io.Serializable;
-import java.sql.ResultSet;
import java.sql.Connection;
+import java.sql.ResultSet;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
@@ -31,6 +31,7 @@
import org.apache.openjpa.conf.OpenJPAConfiguration;
import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
import org.apache.openjpa.jdbc.meta.ClassMapping;
+import org.apache.openjpa.jdbc.sql.JoinSyntaxes;
import org.apache.openjpa.kernel.FetchConfiguration;
import org.apache.openjpa.kernel.FetchConfigurationImpl;
import org.apache.openjpa.kernel.StoreContext;
@@ -121,6 +122,13 @@
}
public JDBCFetchConfiguration setEagerFetchMode(int mode) {
+ if (mode != DEFAULT
+ && mode != EagerFetchModes.EAGER_NONE
+ && mode != EagerFetchModes.EAGER_JOIN
+ && mode != EagerFetchModes.EAGER_PARALLEL)
+ throw new IllegalArgumentException(
+ _loc.get("bad-fetch-mode", new Integer(mode)).getMessage());
+
if (mode == DEFAULT) {
JDBCConfiguration conf = getJDBCConfiguration();
if (conf != null)
@@ -145,6 +153,13 @@
}
public JDBCFetchConfiguration setSubclassFetchMode(int mode) {
+ if (mode != DEFAULT
+ && mode != EagerFetchModes.EAGER_NONE
+ && mode != EagerFetchModes.EAGER_JOIN
+ && mode != EagerFetchModes.EAGER_PARALLEL)
+ throw new IllegalArgumentException(
+ _loc.get("bad-fetch-mode", new Integer(mode)).getMessage());
+
if (mode == DEFAULT) {
JDBCConfiguration conf = getJDBCConfiguration();
if (conf != null)
@@ -160,6 +175,13 @@
}
public JDBCFetchConfiguration setResultSetType(int type) {
+ if (type != DEFAULT
+ && type != ResultSet.TYPE_FORWARD_ONLY
+ && type != ResultSet.TYPE_SCROLL_INSENSITIVE
+ && type != ResultSet.TYPE_SCROLL_SENSITIVE)
+ throw new IllegalArgumentException(_loc.get("bad-resultset-type",
+ new Integer(type)).getMessage());
+
if (type == DEFAULT) {
JDBCConfiguration conf = getJDBCConfiguration();
if (conf != null)
@@ -174,6 +196,13 @@
}
public JDBCFetchConfiguration setFetchDirection(int direction) {
+ if (direction != DEFAULT
+ && direction != ResultSet.FETCH_FORWARD
+ && direction != ResultSet.FETCH_REVERSE
+ && direction != ResultSet.FETCH_UNKNOWN)
+ throw new IllegalArgumentException(_loc.get("bad-fetch-direction",
+ new Integer(direction)).getMessage());
+
if (direction == DEFAULT) {
JDBCConfiguration conf = getJDBCConfiguration();
if (conf != null)
@@ -188,6 +217,13 @@
}
public JDBCFetchConfiguration setLRSSize(int size) {
+ if (size != DEFAULT
+ && size != LRSSizes.SIZE_QUERY
+ && size != LRSSizes.SIZE_LAST
+ && size != LRSSizes.SIZE_UNKNOWN)
+ throw new IllegalArgumentException(
+ _loc.get("bad-lrs-size", new Integer(size)).getMessage());
+
if (size == DEFAULT) {
JDBCConfiguration conf = getJDBCConfiguration();
if (conf != null)
@@ -202,6 +238,13 @@
}
public JDBCFetchConfiguration setJoinSyntax(int syntax) {
+ if (syntax != DEFAULT
+ && syntax != JoinSyntaxes.SYNTAX_SQL92
+ && syntax != JoinSyntaxes.SYNTAX_TRADITIONAL
+ && syntax != JoinSyntaxes.SYNTAX_DATABASE)
+ throw new IllegalArgumentException(
+ _loc.get("bad-join-syntax", new Integer(syntax)).getMessage());
+
if (syntax == DEFAULT) {
JDBCConfiguration conf = getJDBCConfiguration();
if (conf != null)
Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java?rev=762161&r1=762160&r2=762161&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java Sun Apr 5 21:29:42 2009
@@ -38,6 +38,7 @@
import org.apache.openjpa.jdbc.schema.Sequence;
import org.apache.openjpa.jdbc.schema.Table;
import org.apache.openjpa.kernel.Filters;
+import org.apache.openjpa.kernel.MixedLockLevels;
import org.apache.openjpa.lib.util.Localizer;
import org.apache.openjpa.meta.JavaTypes;
import org.apache.openjpa.util.OpenJPAException;
@@ -349,6 +350,9 @@
else
isolationLevel = conf.getTransactionIsolationConstant();
+ if (fetch.getReadLockLevel() >= MixedLockLevels.LOCK_PESSIMISTIC_WRITE)
+ isolationLevel = Connection.TRANSACTION_SERIALIZABLE;
+
if (isForUpdate) {
switch (db2ServerType) {
case db2ISeriesV5R3OrEarlier:
Modified: openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/kernel/localizer.properties
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/kernel/localizer.properties?rev=762161&r1=762160&r2=762161&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/kernel/localizer.properties (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/kernel/localizer.properties Sun Apr 5 21:29:42 2009
@@ -1,145 +1,154 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-error-rollback: An error occurred attempting to rollback to the savepoint "{0}"
-error-save: An error occurred attempting to set the savepoint "{0}". This \
- driver may not support JDBC 3 savepoints.
-mult-mapping-aggregate: Cannot perform an aggregate query on a hierarchy with \
- unjoined subclasses: {0}
-sqlquery-missing-params: SQL query "{0}" declares a parameter index "{1}" for \
- which no value was given. The given parameters were: {2}
-sqlquery-fewer-params: SQL query "{0}" declares {1} distinct parameter(s), \
- but only {2} parameters are given. Given parameter values are "{3}".
-no-sql: You have not specified a SQL filter to execute in your SQL query.
-del-ins-cycle: An unresolvable constraint cycle was detected. This typically \
- means that you are persisting a new object with the same primary key value \
- as an object you are deleting in the same transaction, and at the same \
- time you have circular foreign key dependencies in the transaction. The \
- combination of these two factors can sometimes lead to a situation in \
- which OpenJPA cannot meet all the database constraints.
-ref-cycle: An unresolvable constraint cycle was detected. This typically \
- means that a mapping in a table other than the class'' primary table has \
- a foreign key that is part of a circular foreign key dependency. OpenJPA \
- sometimes cannot meet circular dependencies when some of the involved \
- mappings are in secondary tables.
-update-failed-no-failed-obj: Database operation failed. Update count for SQL \
- statement was {0}. Statement: {1}
-virtual-mapping: Cannot instantiate virtual mapping "{0}".
-press-key-end: Server running. Press enter to stop.
-no-server-conf: There is no persistence server configured.
-server-usage: Usage: \
- java org.apache.openjpa.jdbc.kernel.StartPersistenceServer\n\
- \t[-properties/-p <properties file or resource>]\n\
- \t[-<property name> <property value>]*
-cant-lock-on-load: The database is unable to lock this query. Each object \
- matching the query will be locked individually after it is loaded; \
- however, it is technically possible that another transaction could modify \
- the data before the lock is obtained. See the documentation on Object \
- Locking for details.\n"{0}"
-start-trans-for-lock: Though you are using optimistic transactions, OpenJPA is \
- now beginning a datastore transaction because you have requested a lock \
- on some data.
-millis-query-timeout: JDBC locking does not support millisecond-granularity \
- timeouts. Use timeouts that are multiples of 1000 for even second values.
-batch-not-supported: The update count for the statement was an invalid \
- value ({0}). This indicates that your database or JDBC driver does not \
- have complete support for executing batch statements. Batch \
- functionality should be disabled by including "BatchLimit=0" in \
- your openjpa.jdbc.DBDictionary configuration property. Statement: {1}
-bad-synch-mappings: Invalid SynchronizeMappings operation ("{0}") specified. \
- Valid operations are: {1}
-make-native-seq: Creating sequence.
-drop-native-seq: Dropping sequence.
-make-seq-table: Creating sequence table.
-drop-seq-table: Dropping sequence table.
-bad-seq-up: Attempt to update the sequence table "{0}" failed. The sequence \
- table is typically created when you run the mappingtool''s refresh action \
- on any datastore identity class. If you have not run the mappingtool but \
- want to create the sequence table, run:\n\
- java org.apache.openjpa.jdbc.kernel.TableJDBCSeq -action add
-bad-seq-type: This sequence of type "{0}" cannot generate values for \
- persistent type "{1}".
-no-seq-sql: Error instantiating named sequence "{0}": Your database dictionary \
- does not support native sequences. To tell the dictionary how to select \
- sequence values, use:\n\
- openjpa.jdbc.DBDictionary: NextSequenceQuery="SELECT NEXT VALUE \
- FOR '{0}"\n\
- Where the above string is replaced with the proper SQL for your database.
-invalid-seq-sql: No rows returned for sql "{0}". Check your configuration.
-insert-seq: Inserting row for this mapping into sequence table.
-no-seq-row: There is no row for mapping "{0}" in sequence table "{1}", and \
- the attempt to insert a row has apparently failed.
-update-seq: Updating sequence values.
-null-join: Attempt to add a null/empty fetch join field.
-get-seq: Getting current sequence values.
-seq-usage: Usage: java org.apache.openjpa.jdbc.kernel.TableJDBCSeq\n\
- \t[-properties/-p <properties file or resource>]\n\
- \t[-<property name> <property value>]*\n\
- \t-action/-a <add | drop | get | set> [value]
-clstable-seq-usage: Usage: \
- java org.apache.openjpa.jdbc.kernel.ClassTableJDBCSeq\n\
- \t[-properties/-p <properties file or resource>]\n\
- \t[-<property name> <property value>]*\n\
- \t-action/-a <add | drop | get | set>\n\
- \t[class name | .java file | .class file | .jdo file] [value]
-native-seq-usage: Usage: java org.apache.openjpa.jdbc.kernel.NativeJDBCSeq\n\
- \t[-properties/-p <properties file or resource>]\n\
- \t[-<property name> <property value>]*
-bad-level: Invalid isolation level. Valid levels are -1, \
- Connection.TRANSACTION_NONE, Connection.TRANSACTION_READ_UNCOMMITTED, \
- Connection.TRANSACTION_READ_COMMITTED, \
- Connection.TRANSACTION_REPEATABLE_READ, or \
- Connection.TRANSACTION_SERIALIZABLE. Specified value: {0}.
-no-nullable-fk: No nullable foreign key found to resolve circular flush\n\
- dependency. During flush processing, changes to instances, new\n\
- instances, and deleted instances must be processed in a specific sequence\n\
- to avoid foreign key constraint violations. The changes required in this\n\
- transaction cannot be reordered because none of the foreign key constraints\n\
- is nullable (optional).
-graph-not-cycle-free: A circular flush dependency has been found after all \
- circular dependencies should have been resolved.
-batch_limit: The batch limit is set to {0}.
-batch_update_info: ExecuteBatch command returns update count {0} for \
- statement {1}.
-prepared-query-cached: Query "{0}" is cached as target query "{1}"
-prepared-query-not-cachable: Query "{0}" is not fit for caching.
-prepared-query-invalidate: Query "{0}" is invalidated and removed from cache.
-prepared-query-uncache-strong: Query "{0}" is permanently excluded from cache.
-prepared-query-uncache-weak: Query "{0}" is excluded temporarily due to "{1}".
-prepared-query-add-pattern: Adding a Query exclusion pattern "{0}" has caused \
- following {1} cached queries to be removed from the cache: "{2}".
-prepared-query-remove-pattern: Removing a Query exclusion pattern "{0}" caused \
- following {1} queries to be re-inserted in the cache: "{2}".
-uparam-mismatch: Supplied user parameters "{1}" do not match expected \
- parameters "{0}" for the prepared query "{2}".
-uparam-null: No user parameter was given. Expected parameters "{0}" for the \
- prepared query "{1}".
-uparam-coll-size: Parameter "{0}" has a value "{1}" which is not compatible \
- with the available positions {2} in the parameter list of the prepared query
-uparam-no-pos: User parameter "{0}" does not appear in any position in the \
- prepared query "{1}".
-uparam-pc-key: Class "{0}" uses {1} primary key columns but corresponding \
- positions {2} in the parameter list of the prepared query is not compatible.
-uparam-missing: Parameter {0} in SQL Query "{1}" is not given a value. The \
- parameters given is "{2}".
-finder-cached: Cached finder for "{0}" SQL: "{1}"
-finder-not-cachable: Finder for "{0}" is not cachable.
-finder-add-pattern: Exclusion pattern "{0}" for finder query has invalidated \
- {1} existing entries "{2}"
-optimistic-violation-lock: An optimistic lock violation was detected when \
- locking object instance.
-sql-warning: The statement resulted in SQL warning: {0}
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+error-rollback: An error occurred attempting to rollback to the savepoint "{0}"
+error-save: An error occurred attempting to set the savepoint "{0}". This \
+ driver may not support JDBC 3 savepoints.
+mult-mapping-aggregate: Cannot perform an aggregate query on a hierarchy with \
+ unjoined subclasses: {0}
+sqlquery-missing-params: SQL query "{0}" declares a parameter index "{1}" for \
+ which no value was given. The given parameters were: {2}
+sqlquery-fewer-params: SQL query "{0}" declares {1} distinct parameter(s), \
+ but only {2} parameters are given. Given parameter values are "{3}".
+no-sql: You have not specified a SQL filter to execute in your SQL query.
+del-ins-cycle: An unresolvable constraint cycle was detected. This typically \
+ means that you are persisting a new object with the same primary key value \
+ as an object you are deleting in the same transaction, and at the same \
+ time you have circular foreign key dependencies in the transaction. The \
+ combination of these two factors can sometimes lead to a situation in \
+ which OpenJPA cannot meet all the database constraints.
+ref-cycle: An unresolvable constraint cycle was detected. This typically \
+ means that a mapping in a table other than the class'' primary table has \
+ a foreign key that is part of a circular foreign key dependency. OpenJPA \
+ sometimes cannot meet circular dependencies when some of the involved \
+ mappings are in secondary tables.
+update-failed-no-failed-obj: Database operation failed. Update count for SQL \
+ statement was {0}. Statement: {1}
+virtual-mapping: Cannot instantiate virtual mapping "{0}".
+press-key-end: Server running. Press enter to stop.
+no-server-conf: There is no persistence server configured.
+server-usage: Usage: \
+ java org.apache.openjpa.jdbc.kernel.StartPersistenceServer\n\
+ \t[-properties/-p <properties file or resource>]\n\
+ \t[-<property name> <property value>]*
+cant-lock-on-load: The database is unable to lock this query. Each object \
+ matching the query will be locked individually after it is loaded; \
+ however, it is technically possible that another transaction could modify \
+ the data before the lock is obtained. See the documentation on Object \
+ Locking for details.\n"{0}"
+start-trans-for-lock: Though you are using optimistic transactions, OpenJPA is \
+ now beginning a datastore transaction because you have requested a lock \
+ on some data.
+millis-query-timeout: JDBC locking does not support millisecond-granularity \
+ timeouts. Use timeouts that are multiples of 1000 for even second values.
+batch-not-supported: The update count for the statement was an invalid \
+ value ({0}). This indicates that your database or JDBC driver does not \
+ have complete support for executing batch statements. Batch \
+ functionality should be disabled by including "BatchLimit=0" in \
+ your openjpa.jdbc.DBDictionary configuration property. Statement: {1}
+bad-synch-mappings: Invalid SynchronizeMappings operation ("{0}") specified. \
+ Valid operations are: {1}
+make-native-seq: Creating sequence.
+drop-native-seq: Dropping sequence.
+make-seq-table: Creating sequence table.
+drop-seq-table: Dropping sequence table.
+bad-seq-up: Attempt to update the sequence table "{0}" failed. The sequence \
+ table is typically created when you run the mappingtool''s refresh action \
+ on any datastore identity class. If you have not run the mappingtool but \
+ want to create the sequence table, run:\n\
+ java org.apache.openjpa.jdbc.kernel.TableJDBCSeq -action add
+bad-seq-type: This sequence of type "{0}" cannot generate values for \
+ persistent type "{1}".
+no-seq-sql: Error instantiating named sequence "{0}": Your database dictionary \
+ does not support native sequences. To tell the dictionary how to select \
+ sequence values, use:\n\
+ openjpa.jdbc.DBDictionary: NextSequenceQuery="SELECT NEXT VALUE \
+ FOR '{0}"\n\
+ Where the above string is replaced with the proper SQL for your database.
+invalid-seq-sql: No rows returned for sql "{0}". Check your configuration.
+insert-seq: Inserting row for this mapping into sequence table.
+no-seq-row: There is no row for mapping "{0}" in sequence table "{1}", and \
+ the attempt to insert a row has apparently failed.
+update-seq: Updating sequence values.
+null-join: Attempt to add a null/empty fetch join field.
+get-seq: Getting current sequence values.
+seq-usage: Usage: java org.apache.openjpa.jdbc.kernel.TableJDBCSeq\n\
+ \t[-properties/-p <properties file or resource>]\n\
+ \t[-<property name> <property value>]*\n\
+ \t-action/-a <add | drop | get | set> [value]
+clstable-seq-usage: Usage: \
+ java org.apache.openjpa.jdbc.kernel.ClassTableJDBCSeq\n\
+ \t[-properties/-p <properties file or resource>]\n\
+ \t[-<property name> <property value>]*\n\
+ \t-action/-a <add | drop | get | set>\n\
+ \t[class name | .java file | .class file | .jdo file] [value]
+native-seq-usage: Usage: java org.apache.openjpa.jdbc.kernel.NativeJDBCSeq\n\
+ \t[-properties/-p <properties file or resource>]\n\
+ \t[-<property name> <property value>]*
+bad-level: Invalid isolation level. Valid levels are -1, \
+ "none"(0), "read-uncommitted"(1), "read-committed"(2), \
+ "repeatable-read"(4) or "serializable"(8). Specified value: {0}.
+no-nullable-fk: No nullable foreign key found to resolve circular flush\n\
+ dependency. During flush processing, changes to instances, new\n\
+ instances, and deleted instances must be processed in a specific sequence\n\
+ to avoid foreign key constraint violations. The changes required in this\n\
+ transaction cannot be reordered because none of the foreign key constraints\n\
+ is nullable (optional).
+graph-not-cycle-free: A circular flush dependency has been found after all \
+ circular dependencies should have been resolved.
+batch_limit: The batch limit is set to {0}.
+batch_update_info: ExecuteBatch command returns update count {0} for \
+ statement {1}.
+prepared-query-cached: Query "{0}" is cached as target query "{1}"
+prepared-query-not-cachable: Query "{0}" is not fit for caching.
+prepared-query-invalidate: Query "{0}" is invalidated and removed from cache.
+prepared-query-uncache-strong: Query "{0}" is permanently excluded from cache.
+prepared-query-uncache-weak: Query "{0}" is excluded temporarily due to "{1}".
+prepared-query-add-pattern: Adding a Query exclusion pattern "{0}" has caused \
+ following {1} cached queries to be removed from the cache: "{2}".
+prepared-query-remove-pattern: Removing a Query exclusion pattern "{0}" caused \
+ following {1} queries to be re-inserted in the cache: "{2}".
+uparam-mismatch: Supplied user parameters "{1}" do not match expected \
+ parameters "{0}" for the prepared query "{2}".
+uparam-null: No user parameter was given. Expected parameters "{0}" for the \
+ prepared query "{1}".
+uparam-coll-size: Parameter "{0}" has a value "{1}" which is not compatible \
+ with the available positions {2} in the parameter list of the prepared query
+uparam-no-pos: User parameter "{0}" does not appear in any position in the \
+ prepared query "{1}".
+uparam-pc-key: Class "{0}" uses {1} primary key columns but corresponding \
+ positions {2} in the parameter list of the prepared query is not compatible.
+uparam-missing: Parameter {0} in SQL Query "{1}" is not given a value. The \
+ parameters given is "{2}".
+finder-cached: Cached finder for "{0}" SQL: "{1}"
+finder-not-cachable: Finder for "{0}" is not cachable.
+finder-add-pattern: Exclusion pattern "{0}" for finder query has invalidated \
+ {1} existing entries "{2}"
+optimistic-violation-lock: An optimistic lock violation was detected when \
+ locking object instance.
+sql-warning: The statement resulted in SQL warning: {0}
+bad-fetch-mode: Invalid fetch mode. Valid values are \
+ "none"(0), "join"(1) or "parallel"(2). Specified value: {0}.
+bad-resultset-type: Invalid result set type. Valid values are \
+ "forward-only"(1003), "scroll-insensitive"(1004) or \
+ "scroll-sensitive"(1005). Specified value: {0}.
+bad-fetch-direction: Invalid fetch direction. Valid values are \
+ "forward"(1000), "reverse"(1001) or "unknown"(1002). Specified value: {0}.
+bad-lrs-size: Invalid LRS size. Valid values are \
+ "unknown"(0), "last"(1) or "query"(2). Specified value: {0}.
+bad-join-syntax: Invalid join syntax. Valid values are \
+ "sql92"(0), "tradition"(1) or "database"(2). Specified value: {0}.
Added: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractHintHandler.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractHintHandler.java?rev=762161&view=auto
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractHintHandler.java (added)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractHintHandler.java Sun Apr 5 21:29:42 2009
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.kernel;
+
+import java.io.Serializable;
+import java.lang.reflect.Method;
+
+import org.apache.openjpa.conf.OpenJPAConfiguration;
+import org.apache.openjpa.enhance.Reflection;
+import org.apache.openjpa.lib.util.Localizer;
+
+/**
+ * Default hint handler abstract base class.
+ *
+ * @since 2.0.0
+ * @nojavadoc
+ */
+public abstract class AbstractHintHandler implements Serializable {
+
+ private static final Localizer _loc = Localizer
+ .forPackage(AbstractHintHandler.class);
+
+ protected static final String DOT = ".";
+ protected static final String BLANK = "";
+
+ protected static final String PREFIX_OPENJPA = "openjpa.";
+ protected static final String PREFIX_JDBC = PREFIX_OPENJPA + "jdbc.";
+
+ protected FetchConfigurationImpl _fConfig;
+
+ /**
+ * Constructor; supply delegate.
+ */
+ public AbstractHintHandler(FetchConfigurationImpl fConfig) {
+ _fConfig = fConfig;
+ }
+
+ protected abstract boolean setHintInternal(String hintName, Object value,
+ boolean validateThrowException);
+
+ public boolean setHint(String hintName, Object value,
+ boolean validateThrowException) {
+ String key = hintToKey(hintName);
+ boolean valueSet = !hintName.equals(key);
+ if (hasPrecedent(hintName)) {
+ try {
+ valueSet |= setHintInternal(key, value, validateThrowException);
+ } catch (RuntimeException rte) {
+ if (validateThrowException) {
+ if (rte instanceof IllegalArgumentException)
+ throw rte;
+ else if (rte instanceof ClassCastException)
+ throw new IllegalArgumentException(_loc.get(
+ "bad-hint-value", key, value, rte.getMessage())
+ .getMessage());
+ else
+ handleException(rte);
+ } else
+ _fConfig.getContext().getConfiguration().getLog(
+ OpenJPAConfiguration.LOG_RUNTIME)
+ .warn(
+ _loc.get("bad-hint-value", key, value, rte
+ .getMessage()));
+ }
+ } else
+ valueSet = true;
+ return valueSet;
+ }
+
+ protected String hintToKey(String key) {
+ return key;
+ }
+
+ protected boolean hasPrecedent(String key) {
+ return true;
+ }
+
+ protected void handleException(RuntimeException e) {
+ throw e;
+ }
+
+ protected final boolean hintToSetter(Object target, String k,
+ Object value) {
+ if (target == null || k == null)
+ return false;
+ // remove key prefix as the source of property name
+ k = getSuffixOf(k);
+ Method setter = Reflection.findSetter(target.getClass(), k, true);
+ Class paramType = setter.getParameterTypes()[0];
+ if (Enum.class.isAssignableFrom(paramType) && value instanceof String) {
+ // to accomodate alias name input in relationship with enum values
+ String strValue = ((String) value).toUpperCase().replace('-', '_');
+ value = Enum.valueOf(paramType, strValue);
+ }
+ Filters.hintToSetter(target, k, value);
+ return true;
+ }
+
+ protected static String getPrefixOf(String key) {
+ int firstDot = key == null ? -1 : key.indexOf(DOT);
+ return (firstDot != -1) ? key.substring(0, firstDot) : key;
+ }
+
+ protected static String getSuffixOf(String key) {
+ int lastDot = key == null ? -1 : key.lastIndexOf(DOT);
+ return (lastDot != -1) ? key.substring(lastDot + 1) : key;
+ }
+}
Propchange: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractHintHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingFetchConfiguration.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingFetchConfiguration.java?rev=762161&r1=762160&r2=762161&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingFetchConfiguration.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingFetchConfiguration.java Sun Apr 5 21:29:42 2009
@@ -475,6 +475,14 @@
}
}
+ public void addHint(String name, Object value) {
+ try {
+ _fetch.addHint(name, value);
+ } catch (RuntimeException re) {
+ throw translate(re);
+ }
+ }
+
public Map<String, Object> getHints() {
try {
return _fetch.getHints();
Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfiguration.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfiguration.java?rev=762161&r1=762160&r2=762161&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfiguration.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfiguration.java Sun Apr 5 21:29:42 2009
@@ -337,6 +337,15 @@
*/
public Object getHint (String name);
+ /**
+ * Adds the hint and the associated value to the list.
+ *
+ * @param name the name of the hint
+ * @param value the value of the hint
+ * @since 2.0.0
+ */
+ public void addHint(String name, Object value);
+
/**
* Returns an immutable view of the currently active hints and their values.
*
Added: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationHintHandler.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationHintHandler.java?rev=762161&view=auto
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationHintHandler.java (added)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationHintHandler.java Sun Apr 5 21:29:42 2009
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.kernel;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Fetch configuration hint handler. Handles openjpa.* and openjpa.jdbc.* hints.
+ *
+ * @since 2.0.0
+ * @nojavadoc
+ */
+public class FetchConfigurationHintHandler extends AbstractHintHandler {
+
+ protected static final Map<String, String> hintsMap =
+ new HashMap<String, String>();
+
+ static {
+ // Initialize hint to property name mapping.
+ hintsMap.put(PREFIX_JDBC + "TransactionIsolation", "Isolation");
+ }
+
+ /**
+ * Constructor; supply delegate.
+ */
+ public FetchConfigurationHintHandler(FetchConfigurationImpl fConfig) {
+ super(fConfig);
+ }
+
+ public boolean setHintInternal(String hintName, Object value,
+ boolean validateThrowException) {
+ boolean valueSet = false;
+ String longPrefix = hintName
+ .substring(0, hintName.lastIndexOf(DOT) + 1);
+ if ((longPrefix.equals(PREFIX_JDBC) || longPrefix
+ .equals(PREFIX_OPENJPA))) {
+ valueSet = hintToSetter(_fConfig, hintToPropName(hintName), value);
+ } else {
+ valueSet = true;
+ }
+ return valueSet;
+ }
+
+ private String hintToPropName(String hintName) {
+ String propName = hintsMap.get(hintName);
+ if (propName == null) {
+ propName = hintName;
+ }
+ return propName;
+ }
+}
Propchange: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationHintHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java?rev=762161&r1=762160&r2=762161&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java Sun Apr 5 21:29:42 2009
@@ -98,6 +98,7 @@
private boolean _load = true;
private int _availableRecursion;
private int _availableDepth;
+ private FetchConfigurationHintHandler _hintHandler;
public FetchConfigurationImpl() {
this(null);
@@ -106,6 +107,7 @@
protected FetchConfigurationImpl(ConfigurationState state) {
_state = (state == null) ? new ConfigurationState() : state;
_availableDepth = _state.maxFetchDepth;
+ _hintHandler = new FetchConfigurationHintHandler(this);
}
public StoreContext getContext() {
@@ -239,6 +241,13 @@
}
public FetchConfiguration setFlushBeforeQueries(int flush) {
+ if (flush != DEFAULT
+ && flush != QueryFlushModes.FLUSH_TRUE
+ && flush != QueryFlushModes.FLUSH_FALSE
+ && flush != QueryFlushModes.FLUSH_WITH_CONNECTION)
+ throw new IllegalArgumentException(_loc.get(
+ "bad-flush-before-queries", new Integer(flush)).getMessage());
+
if (flush == DEFAULT && _state.ctx != null)
_state.flushQuery = _state.ctx.getConfiguration().
getFlushBeforeQueriesConstant();
@@ -455,13 +464,15 @@
public int getReadLockLevel() {
- String hintKey = "openjpa.FetchPlan.ReadLockLevel";
- if (getHint(hintKey) != null) {
+ String lockModeKey = "openjpa.FetchPlan.ReadLockMode";
+ String deferLockModeKey = lockModeKey + ".Defer";
+ Integer value = (Integer)getHint(deferLockModeKey);
+ if (value != null) {
if (isActiveTransaction()) {
- setReadLockLevel((Integer)removeHint(hintKey));
- } else {
- return (Integer)getHint(hintKey);
- }
+ removeHint(deferLockModeKey);
+ setReadLockLevel(value);
+ } else
+ return value;
}
return _state.readLockLevel;
}
@@ -470,6 +481,16 @@
if (_state.ctx == null)
return this;
+ if (level != DEFAULT
+ && level != MixedLockLevels.LOCK_NONE
+ && level != MixedLockLevels.LOCK_OPTIMISTIC
+ && level != MixedLockLevels.LOCK_OPTIMISTIC_FORCE_INCREMENT
+ && level != MixedLockLevels.LOCK_PESSIMISTIC_READ
+ && level != MixedLockLevels.LOCK_PESSIMISTIC_WRITE
+ && level != MixedLockLevels.LOCK_PESSIMISTIC_FORCE_INCREMENT)
+ throw new IllegalArgumentException(_loc.get(
+ "bad-lock-level", new Integer(level)).getMessage());
+
lock();
try {
assertActiveTransaction();
@@ -485,13 +506,15 @@
}
public int getWriteLockLevel() {
- String hintKey = "openjpa.FetchPlan.WriteLockLevel";
- if (getHint(hintKey) != null) {
+ String lockModeKey = "openjpa.FetchPlan.WriteLockMode";
+ String deferLockModeKey = lockModeKey + ".Defer";
+ Integer value = (Integer)getHint(deferLockModeKey);
+ if (value != null) {
if (isActiveTransaction()) {
- setReadLockLevel((Integer)removeHint(hintKey));
- } else {
- return (Integer)getHint(hintKey);
- }
+ removeHint(deferLockModeKey);
+ setWriteLockLevel(value);
+ } else
+ return value;
}
return _state.writeLockLevel;
}
@@ -500,6 +523,16 @@
if (_state.ctx == null)
return this;
+ if (level != DEFAULT
+ && level != MixedLockLevels.LOCK_NONE
+ && level != MixedLockLevels.LOCK_OPTIMISTIC
+ && level != MixedLockLevels.LOCK_OPTIMISTIC_FORCE_INCREMENT
+ && level != MixedLockLevels.LOCK_PESSIMISTIC_READ
+ && level != MixedLockLevels.LOCK_PESSIMISTIC_WRITE
+ && level != MixedLockLevels.LOCK_PESSIMISTIC_FORCE_INCREMENT)
+ throw new IllegalArgumentException(_loc.get(
+ "bad-lock-level", new Integer(level)).getMessage());
+
lock();
try {
assertActiveTransaction();
@@ -537,6 +570,16 @@
}
public void setHint(String name, Object value) {
+ setHint(name, value, false);
+ }
+
+ public void setHint(String name, Object value,
+ boolean validThrowException) {
+ if(_hintHandler.setHint(name, value, validThrowException))
+ addHint(name, value);
+ }
+
+ public void addHint(String name, Object value) {
lock();
try {
if (_state.hints == null)
@@ -550,7 +593,7 @@
public Object getHint(String name) {
return (_state.hints == null) ? null : _state.hints.get(name);
}
-
+
public Object removeHint(String name) {
return (_state.hints == null) ? null : _state.hints.remove(name);
}