OPENJPA-1762: lock join table when pessimistic scope is set to EXTENDED

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1032686 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Fay Wang 2010-11-08 20:10:45 +00:00
parent 3c52abb73d
commit 0836fba158
2 changed files with 12 additions and 3 deletions
openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel
openjpa-persistence/src/main/java/org/apache/openjpa/persistence

View File

@ -34,6 +34,7 @@ import org.apache.openjpa.jdbc.sql.DBDictionary;
import org.apache.openjpa.jdbc.sql.SQLBuffer;
import org.apache.openjpa.jdbc.sql.SQLFactory;
import org.apache.openjpa.jdbc.sql.Select;
import org.apache.openjpa.kernel.LockScopes;
import org.apache.openjpa.kernel.MixedLockLevels;
import org.apache.openjpa.kernel.OpenJPAStateManager;
import org.apache.openjpa.kernel.StoreContext;
@ -128,7 +129,8 @@ public class PessimisticLockManager
ClassMapping mapping = (ClassMapping) sm.getMetaData();
List<SQLBuffer> sqls = getLockRows(dict, id, mapping, fetch, _store.getSQLFactory());
lockJoinTables(sqls, dict, id, mapping, fetch, _store.getSQLFactory());
if (ctx.getFetchConfiguration().getLockScope() == LockScopes.LOCKSCOPE_EXTENDED)
lockJoinTables(sqls, dict, id, mapping, fetch, _store.getSQLFactory());
ensureStoreManagerTransaction();
Connection conn = _store.getConnection();

View File

@ -43,6 +43,7 @@ import javax.persistence.CacheStoreMode;
import javax.persistence.EntityManager;
import javax.persistence.FlushModeType;
import javax.persistence.LockModeType;
import javax.persistence.PessimisticLockScope;
import javax.persistence.Query;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaQuery;
@ -1682,8 +1683,14 @@ public class EntityManagerImpl
LockModeType lock, boolean requiresTxn) {
// handle properties in map first
if (properties != null) {
for (Map.Entry<String, Object> entry : properties.entrySet())
fetch.setHint(entry.getKey(), entry.getValue());
for (Map.Entry<String, Object> entry : properties.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if (key.equals("javax.persistence.lock.scope")) {
fetch.setLockScope((PessimisticLockScope)value);
} else
fetch.setHint(key, value);
}
}
// override with the specific lockMode, if needed.
if (lock != null && lock != LockModeType.NONE) {