OPENJPA-2670 improve support for createEnittyManager with SynchronizationType

Currently we support the 'old' SynchronizationType.SYNCHRONIZED behaviour at least.
UNSYNCHRONIZED still needs to be implemented.


git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1763471 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Struberg 2016-10-05 17:20:39 +00:00
parent 19a59684f0
commit e0c03c5fc9
1 changed files with 24 additions and 13 deletions

View File

@ -152,6 +152,17 @@ public class EntityManagerFactoryImpl
return createEntityManager((Map) null);
}
@Override
public OpenJPAEntityManagerSPI createEntityManager(SynchronizationType synchronizationType) {
return createEntityManager(synchronizationType, null);
}
@Override
public OpenJPAEntityManagerSPI createEntityManager(Map props) {
return createEntityManager(SynchronizationType.SYNCHRONIZED, props);
}
/**
* Creates and configures a entity manager with the given properties.
*
@ -159,11 +170,21 @@ public class EntityManagerFactoryImpl
*
* @return list of exceptions raised or empty list.
*/
public OpenJPAEntityManagerSPI createEntityManager(Map props) {
if (props == null)
public OpenJPAEntityManagerSPI createEntityManager(SynchronizationType synchronizationType, Map props) {
if (synchronizationType == null) {
throw new NullPointerException("SynchronizationType must not be null");
}
if (SynchronizationType.UNSYNCHRONIZED.equals(synchronizationType)) {
throw new UnsupportedOperationException("TODO - implement JPA 2.1 feature");
}
if (props == null) {
props = Collections.EMPTY_MAP;
else if (!props.isEmpty())
}
else if (!props.isEmpty()) {
props = new HashMap(props);
}
OpenJPAConfiguration conf = getConfiguration();
Log log = conf.getLog(OpenJPAConfiguration.LOG_RUNTIME);
@ -242,16 +263,6 @@ public class EntityManagerFactoryImpl
return em;
}
@Override
public EntityManager createEntityManager(SynchronizationType synchronizationType) {
throw new UnsupportedOperationException("JPA 2.1");
}
@Override
public EntityManager createEntityManager(SynchronizationType synchronizationType, Map map) {
throw new UnsupportedOperationException("JPA 2.1");
}
/**
* Create a new entity manager around the given broker.
*/