HHH-13548 Since SessionOwner is deprecated several fields in SessionImpl can be removed

This commit is contained in:
Sanne Grinovero 2019-08-07 19:59:45 +01:00
parent 0028c850b9
commit 9b3c9e6f0f
3 changed files with 8 additions and 52 deletions

View File

@ -51,7 +51,7 @@ public interface SessionCreationOptions {
/**
* Access to the SessionOwner, which defines the contract for things that can wrap a Session
*
* @return The SessionOwner
* @return Always returns null.
*
* @deprecated (since 5,2) SessionOwner is no longer pertinent due to the
* hibernate-entitymanager -> hibernate-core consolidation

View File

@ -1154,7 +1154,6 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
private static final Logger log = CoreLogging.logger( SessionBuilderImpl.class );
private final SessionFactoryImpl sessionFactory;
private SessionOwner sessionOwner;
private Interceptor interceptor;
private StatementInspector statementInspector;
private Connection connection;
@ -1175,7 +1174,6 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
SessionBuilderImpl(SessionFactoryImpl sessionFactory) {
this.sessionFactory = sessionFactory;
this.sessionOwner = null;
// set up default builder values...
final SessionFactoryOptions sessionFactoryOptions = sessionFactory.getSessionFactoryOptions();
@ -1202,26 +1200,18 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
@Override
public SessionOwner getSessionOwner() {
return sessionOwner;
return null;
}
@Override
public ExceptionMapper getExceptionMapper() {
if ( sessionOwner != null ) {
return sessionOwner.getExceptionMapper();
}
else {
return sessionOwnerBehavior == SessionOwnerBehavior.LEGACY_JPA
? ExceptionMapperLegacyJpaImpl.INSTANCE
: null;
}
return sessionOwnerBehavior == SessionOwnerBehavior.LEGACY_JPA
? ExceptionMapperLegacyJpaImpl.INSTANCE
: null;
}
@Override
public AfterCompletionAction getAfterCompletionAction() {
if ( sessionOwner != null ) {
return sessionOwner.getAfterCompletionAction();
}
return sessionOwnerBehavior == SessionOwnerBehavior.LEGACY_JPA
? AfterCompletionActionLegacyJpaImpl.INSTANCE
: null;
@ -1229,9 +1219,6 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
@Override
public ManagedFlushChecker getManagedFlushChecker() {
if ( sessionOwner != null ) {
return sessionOwner.getManagedFlushChecker();
}
return sessionOwnerBehavior == SessionOwnerBehavior.LEGACY_JPA
? ManagedFlushCheckerLegacyJpaImpl.INSTANCE
: null;
@ -1297,7 +1284,7 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
@Override
public Session openSession() {
log.tracef( "Opening Hibernate Session. tenant=%s, owner=%s", tenantIdentifier, sessionOwner );
log.tracef( "Opening Hibernate Session. tenant=%s", tenantIdentifier );
final SessionImpl session = new SessionImpl( sessionFactory, this );
final SessionEventListenerManager eventListenerManager = session.getEventListenerManager();
@ -1311,8 +1298,7 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
@Override
@SuppressWarnings("unchecked")
public T owner(SessionOwner sessionOwner) {
this.sessionOwner = sessionOwner;
return (T) this;
throw new UnsupportedOperationException( "SessionOwner was long deprecated and this method should no longer be invoked" );
}
@Override

View File

@ -91,7 +91,6 @@ import org.hibernate.engine.spi.PersistenceContext;
import org.hibernate.engine.spi.QueryParameters;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.engine.spi.SessionOwner;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.engine.spi.Status;
import org.hibernate.engine.spi.TypedValue;
@ -172,7 +171,6 @@ import org.hibernate.query.spi.ScrollableResultsImplementor;
import org.hibernate.resource.transaction.TransactionRequiredForJoinException;
import org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorImpl;
import org.hibernate.resource.transaction.backend.jta.internal.synchronization.AfterCompletionAction;
import org.hibernate.resource.transaction.backend.jta.internal.synchronization.ExceptionMapper;
import org.hibernate.resource.transaction.backend.jta.internal.synchronization.ManagedFlushChecker;
import org.hibernate.resource.transaction.spi.TransactionCoordinator;
import org.hibernate.resource.transaction.spi.TransactionStatus;
@ -215,8 +213,6 @@ public final class SessionImpl
QueryHints.SPEC_HINT_TIMEOUT
};
private transient SessionOwner sessionOwner;
private Map<String, Object> properties = new HashMap<>();
private transient ActionQueue actionQueue;
@ -233,8 +229,6 @@ public final class SessionImpl
private transient int dontFlushFromFind;
private transient ExceptionMapper exceptionMapper;
private transient LoadEvent loadEvent; //cached LoadEvent instance
private transient boolean discardOnClose;
@ -248,9 +242,6 @@ public final class SessionImpl
this.actionQueue = new ActionQueue( this );
this.persistenceContext = new StatefulPersistenceContext( this );
this.sessionOwner = options.getSessionOwner();
initializeFromSessionOwner( sessionOwner );
this.autoClear = options.shouldAutoClear();
this.autoClose = options.shouldAutoClose();
this.queryParametersValidationEnabled = options.isQueryParametersValidationEnabled();
@ -338,21 +329,6 @@ public final class SessionImpl
return determineCacheStoreMode( properties );
}
private void initializeFromSessionOwner(SessionOwner sessionOwner) {
if ( sessionOwner != null ) {
if ( sessionOwner.getExceptionMapper() != null ) {
exceptionMapper = sessionOwner.getExceptionMapper();
}
else {
exceptionMapper = ExceptionMapperStandardImpl.INSTANCE;
}
}
else {
exceptionMapper = ExceptionMapperStandardImpl.INSTANCE;
}
}
@Override
public SharedSessionBuilder sessionWithOptions() {
return new SharedSessionBuilderImpl( this );
@ -504,9 +480,6 @@ public final class SessionImpl
else if ( isClosed() ) {
return false;
}
else if ( sessionOwner != null ) {
return sessionOwner.shouldAutoCloseSession();
}
else {
// JPA technically requires that this be a PersistentUnityTransactionType#JTA to work,
// but we do not assert that here...
@ -2639,7 +2612,6 @@ public final class SessionImpl
private SharedSessionBuilderImpl(SessionImpl session) {
super( (SessionFactoryImpl) session.getFactory() );
this.session = session;
super.owner( session.sessionOwner );
super.tenantIdentifier( session.getTenantIdentifier() );
}
@ -3374,7 +3346,7 @@ public final class SessionImpl
}
}
catch (RuntimeException re) {
throw exceptionMapper.mapManagedFlushFailure( "error during managed flush", re, this );
throw ExceptionMapperStandardImpl.INSTANCE.mapManagedFlushFailure( "error during managed flush", re, this );
}
}
@ -3955,8 +3927,6 @@ public final class SessionImpl
( (FilterImpl) loadQueryInfluencers.getEnabledFilter( filterName ) ).afterDeserialize( getFactory() );
}
initializeFromSessionOwner( null );
this.discardOnClose = getFactory().getSessionFactoryOptions().isReleaseResourcesOnCloseEnabled();
}
}