OPENJPA-1578: Set CacheMode properties properly

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@923755 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Pinaki Poddar 2010-03-16 14:30:53 +00:00
parent 8a1e0307f2
commit 845f9b5018
3 changed files with 17 additions and 3 deletions

View File

@ -78,6 +78,7 @@ import org.apache.openjpa.meta.FieldMetaData;
import org.apache.openjpa.meta.JavaTypes;
import org.apache.openjpa.meta.ValueStrategies;
import org.apache.openjpa.util.ApplicationIds;
import org.apache.openjpa.util.Exceptions;
import org.apache.openjpa.util.Id;
import org.apache.openjpa.util.ImplHelper;
import org.apache.openjpa.util.InvalidStateException;
@ -328,7 +329,8 @@ public class JDBCStoreManager
} catch (ClassNotFoundException cnfe) {
throw new UserException(cnfe);
} catch (SQLException se) {
throw SQLExceptions.getStore(se, _dict, fetch.getReadLockLevel());
throw SQLExceptions.getStore(se, Exceptions.toString(sm.getPersistenceCapable()),
_dict, fetch.getReadLockLevel());
}
}

View File

@ -228,6 +228,8 @@ public class FetchConfigurationImpl
addFetchGroups(fetch.getFetchGroups());
clearFields();
copyHints(fetch);
setCacheRetrieveMode(fetch.getCacheRetrieveMode());
setCacheStoreMode(fetch.getCacheStoreMode());
addFields(fetch.getFields());
// don't use setters because require active transaction

View File

@ -482,6 +482,7 @@ public class EntityManagerImpl
@SuppressWarnings("unchecked")
public <T> T find(Class<T> cls, Object oid, LockModeType mode, Map<String, Object> properties) {
assertNotCloseInvoked();
configureCurrentCacheModes(getFetchPlan(), properties);
configureCurrentFetchPlan(pushFetchPlan(), properties, mode, true);
try {
oid = _broker.newObjectId(cls, oid);
@ -1174,7 +1175,7 @@ public class EntityManagerImpl
assertNotCloseInvoked();
assertValidAttchedEntity("lock", entity);
_broker.assertActiveTransaction();
configureCurrentCacheModes(getFetchPlan(), properties);
configureCurrentFetchPlan(pushFetchPlan(), properties, mode, false);
try {
_broker.lock(entity, MixedLockLevelsHelper.toLockLevel(mode),
@ -1663,7 +1664,6 @@ public class EntityManagerImpl
private void configureCurrentFetchPlan(FetchPlan fetch, Map<String, Object> properties,
LockModeType lock, boolean requiresTxn) {
// handle properties in map first
configureCurrentCacheModes(fetch, properties);
if (properties != null) {
for (Map.Entry<String, Object> entry : properties.entrySet())
fetch.setHint(entry.getKey(), entry.getValue());
@ -1680,6 +1680,16 @@ public class EntityManagerImpl
}
}
/**
* Populate the fetch configuration with specified cache mode properties.
* The cache mode properties modify the fetch configuration and remove those
* properties. This method should be called <em>before</em> the fetch configuration of the current
* context has been pushed.
* @param fetch the fetch configuration of the current context. Not the
* new configuration pushed (and later popped) during a single operation.
*
* @param properties
*/
private void configureCurrentCacheModes(FetchPlan fetch, Map<String, Object> properties) {
if (properties == null)
return;