HHH-12097 - EntityManagerFactory open/closed checks per JPA spec

This commit is contained in:
Steve Ebersole 2017-12-06 01:02:23 -06:00
parent 6dc94ff7f7
commit 09a15ac68e
1 changed files with 6 additions and 1 deletions

View File

@ -566,11 +566,13 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
@Override
public Session createEntityManager() {
validateNotClosed();
return buildEntityManager( SynchronizationType.SYNCHRONIZED, Collections.emptyMap() );
}
private Session buildEntityManager(SynchronizationType synchronizationType, Map map) {
validateNotClosed();
assert !isClosed;
SessionBuilderImplementor builder = withOptions();
if ( synchronizationType == SynchronizationType.SYNCHRONIZED ) {
builder.autoJoinTransactions( true );
@ -592,11 +594,13 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
@Override
public Session createEntityManager(Map map) {
validateNotClosed();
return buildEntityManager( SynchronizationType.SYNCHRONIZED, map );
}
@Override
public Session createEntityManager(SynchronizationType synchronizationType) {
validateNotClosed();
errorIfResourceLocalDueToExplicitSynchronizationType();
return buildEntityManager( synchronizationType, Collections.emptyMap() );
}
@ -615,6 +619,7 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
@Override
public Session createEntityManager(SynchronizationType synchronizationType, Map map) {
validateNotClosed();
errorIfResourceLocalDueToExplicitSynchronizationType();
return buildEntityManager( synchronizationType, map );
}