mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-09 20:54:46 +00:00
HHH-13565 Move field AbstractSharedSessionContract#disallowOutOfTransactionUpdateOperations to constants in FastSessionServices
This commit is contained in:
parent
5eaa1498df
commit
a39acebde8
@ -139,7 +139,6 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
|
|||||||
|
|
||||||
protected boolean closed;
|
protected boolean closed;
|
||||||
protected boolean waitingForAutoClose;
|
protected boolean waitingForAutoClose;
|
||||||
private transient boolean disallowOutOfTransactionUpdateOperations;
|
|
||||||
|
|
||||||
// transient & non-final for Serialization purposes - ugh
|
// transient & non-final for Serialization purposes - ugh
|
||||||
private transient SessionEventListenerManagerImpl sessionEventsManager = new SessionEventListenerManagerImpl();
|
private transient SessionEventListenerManagerImpl sessionEventsManager = new SessionEventListenerManagerImpl();
|
||||||
@ -157,7 +156,7 @@ public AbstractSharedSessionContract(SessionFactoryImpl factory, SessionCreation
|
|||||||
this.factory = factory;
|
this.factory = factory;
|
||||||
this.fastSessionServices = factory.getFastSessionServices();
|
this.fastSessionServices = factory.getFastSessionServices();
|
||||||
this.cacheTransactionSync = factory.getCache().getRegionFactory().createTransactionContext( this );
|
this.cacheTransactionSync = factory.getCache().getRegionFactory().createTransactionContext( this );
|
||||||
this.disallowOutOfTransactionUpdateOperations = !factory.getSessionFactoryOptions().isAllowOutOfTransactionUpdateOperations();
|
|
||||||
|
|
||||||
this.flushMode = options.getInitialSessionFlushMode();
|
this.flushMode = options.getInitialSessionFlushMode();
|
||||||
|
|
||||||
@ -407,7 +406,7 @@ public boolean isTransactionInProgress() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void checkTransactionNeededForUpdateOperation(String exceptionMessage) {
|
public void checkTransactionNeededForUpdateOperation(String exceptionMessage) {
|
||||||
if ( disallowOutOfTransactionUpdateOperations && !isTransactionInProgress() ) {
|
if ( fastSessionServices.disallowOutOfTransactionUpdateOperations && !isTransactionInProgress() ) {
|
||||||
throw new TransactionRequiredException( exceptionMessage );
|
throw new TransactionRequiredException( exceptionMessage );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1239,7 +1238,6 @@ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFound
|
|||||||
.buildTransactionCoordinator( jdbcCoordinator, this );
|
.buildTransactionCoordinator( jdbcCoordinator, this );
|
||||||
|
|
||||||
entityNameResolver = new CoordinatingEntityNameResolver( factory, interceptor );
|
entityNameResolver = new CoordinatingEntityNameResolver( factory, interceptor );
|
||||||
this.disallowOutOfTransactionUpdateOperations = !getFactory().getSessionFactoryOptions().isAllowOutOfTransactionUpdateOperations();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,8 @@
|
|||||||
*/
|
*/
|
||||||
final class FastSessionServices {
|
final class FastSessionServices {
|
||||||
|
|
||||||
|
// All session events need to be iterated frequently:
|
||||||
|
|
||||||
private final Iterable<ClearEventListener> clearEventListeners;
|
private final Iterable<ClearEventListener> clearEventListeners;
|
||||||
private final Iterable<SaveOrUpdateEventListener> saveUpdateEventListeners;
|
private final Iterable<SaveOrUpdateEventListener> saveUpdateEventListeners;
|
||||||
private final Iterable<EvictEventListener> evictEventListeners;
|
private final Iterable<EvictEventListener> evictEventListeners;
|
||||||
@ -68,9 +70,14 @@ final class FastSessionServices {
|
|||||||
private final Iterable<InitializeCollectionEventListener> initCollectionEventListeners;
|
private final Iterable<InitializeCollectionEventListener> initCollectionEventListeners;
|
||||||
private final Iterable<ResolveNaturalIdEventListener> resolveNaturalIdEventListeners;
|
private final Iterable<ResolveNaturalIdEventListener> resolveNaturalIdEventListeners;
|
||||||
|
|
||||||
|
//Intentionally Package private:
|
||||||
|
final boolean disallowOutOfTransactionUpdateOperations;
|
||||||
|
|
||||||
FastSessionServices(SessionFactoryImpl sf) {
|
FastSessionServices(SessionFactoryImpl sf) {
|
||||||
Objects.requireNonNull( sf );
|
Objects.requireNonNull( sf );
|
||||||
final ServiceRegistryImplementor sr = sf.getServiceRegistry();
|
final ServiceRegistryImplementor sr = sf.getServiceRegistry();
|
||||||
|
|
||||||
|
// Pre-compute all iterators on Event listeners:
|
||||||
final EventListenerRegistry eventListenerRegistry = sr.getService( EventListenerRegistry.class );
|
final EventListenerRegistry eventListenerRegistry = sr.getService( EventListenerRegistry.class );
|
||||||
this.clearEventListeners = listeners( eventListenerRegistry, EventType.CLEAR );
|
this.clearEventListeners = listeners( eventListenerRegistry, EventType.CLEAR );
|
||||||
this.saveUpdateEventListeners = listeners( eventListenerRegistry, EventType.SAVE_UPDATE );
|
this.saveUpdateEventListeners = listeners( eventListenerRegistry, EventType.SAVE_UPDATE );
|
||||||
@ -90,6 +97,9 @@ final class FastSessionServices {
|
|||||||
this.flushEventListeners = listeners( eventListenerRegistry, EventType.FLUSH );
|
this.flushEventListeners = listeners( eventListenerRegistry, EventType.FLUSH );
|
||||||
this.initCollectionEventListeners = listeners( eventListenerRegistry, EventType.INIT_COLLECTION );
|
this.initCollectionEventListeners = listeners( eventListenerRegistry, EventType.INIT_COLLECTION );
|
||||||
this.resolveNaturalIdEventListeners = listeners( eventListenerRegistry, EventType.RESOLVE_NATURAL_ID );
|
this.resolveNaturalIdEventListeners = listeners( eventListenerRegistry, EventType.RESOLVE_NATURAL_ID );
|
||||||
|
|
||||||
|
//Other highly useful constants:
|
||||||
|
this.disallowOutOfTransactionUpdateOperations = !sf.getSessionFactoryOptions().isAllowOutOfTransactionUpdateOperations();
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterable<ClearEventListener> getClearEventListeners() {
|
Iterable<ClearEventListener> getClearEventListeners() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user