HHH-13548 Since SessionOwner is deprecated several fields in SessionImpl can be removed
This commit is contained in:
parent
0028c850b9
commit
9b3c9e6f0f
|
@ -51,7 +51,7 @@ public interface SessionCreationOptions {
|
||||||
/**
|
/**
|
||||||
* Access to the SessionOwner, which defines the contract for things that can wrap a Session
|
* 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
|
* @deprecated (since 5,2) SessionOwner is no longer pertinent due to the
|
||||||
* hibernate-entitymanager -> hibernate-core consolidation
|
* hibernate-entitymanager -> hibernate-core consolidation
|
||||||
|
|
|
@ -1154,7 +1154,6 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
|
||||||
private static final Logger log = CoreLogging.logger( SessionBuilderImpl.class );
|
private static final Logger log = CoreLogging.logger( SessionBuilderImpl.class );
|
||||||
|
|
||||||
private final SessionFactoryImpl sessionFactory;
|
private final SessionFactoryImpl sessionFactory;
|
||||||
private SessionOwner sessionOwner;
|
|
||||||
private Interceptor interceptor;
|
private Interceptor interceptor;
|
||||||
private StatementInspector statementInspector;
|
private StatementInspector statementInspector;
|
||||||
private Connection connection;
|
private Connection connection;
|
||||||
|
@ -1175,7 +1174,6 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
|
||||||
|
|
||||||
SessionBuilderImpl(SessionFactoryImpl sessionFactory) {
|
SessionBuilderImpl(SessionFactoryImpl sessionFactory) {
|
||||||
this.sessionFactory = sessionFactory;
|
this.sessionFactory = sessionFactory;
|
||||||
this.sessionOwner = null;
|
|
||||||
|
|
||||||
// set up default builder values...
|
// set up default builder values...
|
||||||
final SessionFactoryOptions sessionFactoryOptions = sessionFactory.getSessionFactoryOptions();
|
final SessionFactoryOptions sessionFactoryOptions = sessionFactory.getSessionFactoryOptions();
|
||||||
|
@ -1202,26 +1200,18 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SessionOwner getSessionOwner() {
|
public SessionOwner getSessionOwner() {
|
||||||
return sessionOwner;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ExceptionMapper getExceptionMapper() {
|
public ExceptionMapper getExceptionMapper() {
|
||||||
if ( sessionOwner != null ) {
|
|
||||||
return sessionOwner.getExceptionMapper();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return sessionOwnerBehavior == SessionOwnerBehavior.LEGACY_JPA
|
return sessionOwnerBehavior == SessionOwnerBehavior.LEGACY_JPA
|
||||||
? ExceptionMapperLegacyJpaImpl.INSTANCE
|
? ExceptionMapperLegacyJpaImpl.INSTANCE
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AfterCompletionAction getAfterCompletionAction() {
|
public AfterCompletionAction getAfterCompletionAction() {
|
||||||
if ( sessionOwner != null ) {
|
|
||||||
return sessionOwner.getAfterCompletionAction();
|
|
||||||
}
|
|
||||||
return sessionOwnerBehavior == SessionOwnerBehavior.LEGACY_JPA
|
return sessionOwnerBehavior == SessionOwnerBehavior.LEGACY_JPA
|
||||||
? AfterCompletionActionLegacyJpaImpl.INSTANCE
|
? AfterCompletionActionLegacyJpaImpl.INSTANCE
|
||||||
: null;
|
: null;
|
||||||
|
@ -1229,9 +1219,6 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ManagedFlushChecker getManagedFlushChecker() {
|
public ManagedFlushChecker getManagedFlushChecker() {
|
||||||
if ( sessionOwner != null ) {
|
|
||||||
return sessionOwner.getManagedFlushChecker();
|
|
||||||
}
|
|
||||||
return sessionOwnerBehavior == SessionOwnerBehavior.LEGACY_JPA
|
return sessionOwnerBehavior == SessionOwnerBehavior.LEGACY_JPA
|
||||||
? ManagedFlushCheckerLegacyJpaImpl.INSTANCE
|
? ManagedFlushCheckerLegacyJpaImpl.INSTANCE
|
||||||
: null;
|
: null;
|
||||||
|
@ -1297,7 +1284,7 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Session openSession() {
|
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 SessionImpl session = new SessionImpl( sessionFactory, this );
|
||||||
|
|
||||||
final SessionEventListenerManager eventListenerManager = session.getEventListenerManager();
|
final SessionEventListenerManager eventListenerManager = session.getEventListenerManager();
|
||||||
|
@ -1311,8 +1298,7 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public T owner(SessionOwner sessionOwner) {
|
public T owner(SessionOwner sessionOwner) {
|
||||||
this.sessionOwner = sessionOwner;
|
throw new UnsupportedOperationException( "SessionOwner was long deprecated and this method should no longer be invoked" );
|
||||||
return (T) this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -91,7 +91,6 @@ import org.hibernate.engine.spi.PersistenceContext;
|
||||||
import org.hibernate.engine.spi.QueryParameters;
|
import org.hibernate.engine.spi.QueryParameters;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.engine.spi.SessionImplementor;
|
import org.hibernate.engine.spi.SessionImplementor;
|
||||||
import org.hibernate.engine.spi.SessionOwner;
|
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.engine.spi.Status;
|
import org.hibernate.engine.spi.Status;
|
||||||
import org.hibernate.engine.spi.TypedValue;
|
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.TransactionRequiredForJoinException;
|
||||||
import org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorImpl;
|
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.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.backend.jta.internal.synchronization.ManagedFlushChecker;
|
||||||
import org.hibernate.resource.transaction.spi.TransactionCoordinator;
|
import org.hibernate.resource.transaction.spi.TransactionCoordinator;
|
||||||
import org.hibernate.resource.transaction.spi.TransactionStatus;
|
import org.hibernate.resource.transaction.spi.TransactionStatus;
|
||||||
|
@ -215,8 +213,6 @@ public final class SessionImpl
|
||||||
QueryHints.SPEC_HINT_TIMEOUT
|
QueryHints.SPEC_HINT_TIMEOUT
|
||||||
};
|
};
|
||||||
|
|
||||||
private transient SessionOwner sessionOwner;
|
|
||||||
|
|
||||||
private Map<String, Object> properties = new HashMap<>();
|
private Map<String, Object> properties = new HashMap<>();
|
||||||
|
|
||||||
private transient ActionQueue actionQueue;
|
private transient ActionQueue actionQueue;
|
||||||
|
@ -233,8 +229,6 @@ public final class SessionImpl
|
||||||
|
|
||||||
private transient int dontFlushFromFind;
|
private transient int dontFlushFromFind;
|
||||||
|
|
||||||
private transient ExceptionMapper exceptionMapper;
|
|
||||||
|
|
||||||
private transient LoadEvent loadEvent; //cached LoadEvent instance
|
private transient LoadEvent loadEvent; //cached LoadEvent instance
|
||||||
|
|
||||||
private transient boolean discardOnClose;
|
private transient boolean discardOnClose;
|
||||||
|
@ -248,9 +242,6 @@ public final class SessionImpl
|
||||||
this.actionQueue = new ActionQueue( this );
|
this.actionQueue = new ActionQueue( this );
|
||||||
this.persistenceContext = new StatefulPersistenceContext( this );
|
this.persistenceContext = new StatefulPersistenceContext( this );
|
||||||
|
|
||||||
this.sessionOwner = options.getSessionOwner();
|
|
||||||
initializeFromSessionOwner( sessionOwner );
|
|
||||||
|
|
||||||
this.autoClear = options.shouldAutoClear();
|
this.autoClear = options.shouldAutoClear();
|
||||||
this.autoClose = options.shouldAutoClose();
|
this.autoClose = options.shouldAutoClose();
|
||||||
this.queryParametersValidationEnabled = options.isQueryParametersValidationEnabled();
|
this.queryParametersValidationEnabled = options.isQueryParametersValidationEnabled();
|
||||||
|
@ -338,21 +329,6 @@ public final class SessionImpl
|
||||||
return determineCacheStoreMode( properties );
|
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
|
@Override
|
||||||
public SharedSessionBuilder sessionWithOptions() {
|
public SharedSessionBuilder sessionWithOptions() {
|
||||||
return new SharedSessionBuilderImpl( this );
|
return new SharedSessionBuilderImpl( this );
|
||||||
|
@ -504,9 +480,6 @@ public final class SessionImpl
|
||||||
else if ( isClosed() ) {
|
else if ( isClosed() ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if ( sessionOwner != null ) {
|
|
||||||
return sessionOwner.shouldAutoCloseSession();
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
// JPA technically requires that this be a PersistentUnityTransactionType#JTA to work,
|
// JPA technically requires that this be a PersistentUnityTransactionType#JTA to work,
|
||||||
// but we do not assert that here...
|
// but we do not assert that here...
|
||||||
|
@ -2639,7 +2612,6 @@ public final class SessionImpl
|
||||||
private SharedSessionBuilderImpl(SessionImpl session) {
|
private SharedSessionBuilderImpl(SessionImpl session) {
|
||||||
super( (SessionFactoryImpl) session.getFactory() );
|
super( (SessionFactoryImpl) session.getFactory() );
|
||||||
this.session = session;
|
this.session = session;
|
||||||
super.owner( session.sessionOwner );
|
|
||||||
super.tenantIdentifier( session.getTenantIdentifier() );
|
super.tenantIdentifier( session.getTenantIdentifier() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3374,7 +3346,7 @@ public final class SessionImpl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (RuntimeException re) {
|
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() );
|
( (FilterImpl) loadQueryInfluencers.getEnabledFilter( filterName ) ).afterDeserialize( getFactory() );
|
||||||
}
|
}
|
||||||
|
|
||||||
initializeFromSessionOwner( null );
|
|
||||||
|
|
||||||
this.discardOnClose = getFactory().getSessionFactoryOptions().isReleaseResourcesOnCloseEnabled();
|
this.discardOnClose = getFactory().getSessionFactoryOptions().isReleaseResourcesOnCloseEnabled();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue