HHH-13471 Avoid invoking delayedAfterCompletion() multiple times from the same SessionImpl method

This commit is contained in:
Sanne Grinovero 2019-06-28 11:00:34 +01:00
parent a9d4c13d86
commit e044397df2
2 changed files with 44 additions and 45 deletions

View File

@ -494,7 +494,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
@Override
public boolean isConnected() {
checkTransactionSynchStatus();
pulseTransactionCoordinator();
return jdbcCoordinator.getLogicalConnection().isOpen();
}
@ -618,7 +618,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
@Override
public QueryImplementor getNamedQuery(String name) {
checkOpen();
checkTransactionSynchStatus();
pulseTransactionCoordinator();
delayedAfterCompletion();
// look as HQL/JPQL first
@ -711,7 +711,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
@Override
public QueryImplementor createQuery(String queryString) {
checkOpen();
checkTransactionSynchStatus();
pulseTransactionCoordinator();
delayedAfterCompletion();
try {
@ -737,7 +737,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
@SuppressWarnings("unchecked")
public <T> QueryImplementor<T> createQuery(String queryString, Class<T> resultClass) {
checkOpen();
checkTransactionSynchStatus();
pulseTransactionCoordinator();
delayedAfterCompletion();
try {
@ -810,7 +810,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
protected <T> QueryImplementor<T> buildQueryFromName(String name, Class<T> resultType) {
checkOpen();
try {
checkTransactionSynchStatus();
pulseTransactionCoordinator();
delayedAfterCompletion();
// todo : apply stored setting at the JPA Query level too
@ -934,7 +934,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
@Override
public NativeQueryImplementor createNativeQuery(String sqlString, Class resultClass) {
checkOpen();
checkTransactionSynchStatus();
pulseTransactionCoordinator();
delayedAfterCompletion();
try {
@ -959,7 +959,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
@Override
public NativeQueryImplementor createNativeQuery(String sqlString, String resultSetMapping) {
checkOpen();
checkTransactionSynchStatus();
pulseTransactionCoordinator();
delayedAfterCompletion();
try {
@ -975,7 +975,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
@Override
public NativeQueryImplementor getNamedNativeQuery(String name) {
checkOpen();
checkTransactionSynchStatus();
pulseTransactionCoordinator();
delayedAfterCompletion();
final NamedSQLQueryDefinition nativeQueryDefinition = factory.getNamedQueryRepository().getNamedSQLQueryDefinition( name );
@ -995,7 +995,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
String queryString,
boolean isOrdinalParameterZeroBased) {
checkOpen();
checkTransactionSynchStatus();
pulseTransactionCoordinator();
delayedAfterCompletion();
try {

View File

@ -763,7 +763,7 @@ public final class SessionImpl
private void fireLock(LockEvent event) {
checkOpen();
checkTransactionSynchStatus();
pulseTransactionCoordinator();
for ( LockEventListener listener : listeners( EventType.LOCK ) ) {
listener.onLock( event );
}
@ -817,7 +817,7 @@ public final class SessionImpl
}
private void firePersist(Map copiedAlready, PersistEvent event) {
checkTransactionSynchStatus();
pulseTransactionCoordinator();
try {
for ( PersistEventListener listener : listeners( EventType.PERSIST ) ) {
@ -855,7 +855,7 @@ public final class SessionImpl
private void firePersistOnFlush(Map copiedAlready, PersistEvent event) {
checkOpenOrWaitingForAutoClose();
checkTransactionSynchStatus();
pulseTransactionCoordinator();
for ( PersistEventListener listener : listeners( EventType.PERSIST_ONFLUSH ) ) {
listener.onPersist( event, copiedAlready );
}
@ -918,7 +918,7 @@ public final class SessionImpl
private void fireMerge(Map copiedAlready, MergeEvent event) {
try {
checkTransactionSynchStatus();
pulseTransactionCoordinator();
for ( MergeEventListener listener : listeners( EventType.MERGE ) ) {
listener.onMerge( event, copiedAlready );
}
@ -1006,7 +1006,7 @@ public final class SessionImpl
private void fireDelete(DeleteEvent event) {
try{
checkTransactionSynchStatus();
pulseTransactionCoordinator();
for ( DeleteEventListener listener : listeners( EventType.DELETE ) ) {
listener.onDelete( event );
}
@ -1028,10 +1028,10 @@ public final class SessionImpl
private void fireDelete(DeleteEvent event, Set transientEntities) {
try{
checkTransactionSynchStatus();
for ( DeleteEventListener listener : listeners( EventType.DELETE ) ) {
listener.onDelete( event, transientEntities );
}
pulseTransactionCoordinator();
for ( DeleteEventListener listener : listeners( EventType.DELETE ) ) {
listener.onDelete( event, transientEntities );
}
}
catch ( ObjectDeletedException sse ) {
throw exceptionConverter.convert( new IllegalArgumentException( sse ) );
@ -1287,7 +1287,7 @@ public final class SessionImpl
private void fireResolveNaturalId(ResolveNaturalIdEvent event) {
checkOpenOrWaitingForAutoClose();
checkTransactionSynchStatus();
pulseTransactionCoordinator();
for ( ResolveNaturalIdEventListener listener : listeners( EventType.RESOLVE_NATURAL_ID ) ) {
listener.onResolveNaturalId( event );
}
@ -1347,7 +1347,7 @@ public final class SessionImpl
}
}
}
checkTransactionSynchStatus();
pulseTransactionCoordinator();
for ( RefreshEventListener listener : listeners( EventType.REFRESH ) ) {
listener.onRefresh( event );
}
@ -1368,11 +1368,10 @@ public final class SessionImpl
private void fireRefresh(Map refreshedAlready, RefreshEvent event) {
try {
checkTransactionSynchStatus();
pulseTransactionCoordinator();
for ( RefreshEventListener listener : listeners( EventType.REFRESH ) ) {
listener.onRefresh( event, refreshedAlready );
}
delayedAfterCompletion();
}
catch (RuntimeException e) {
throw exceptionConverter.convert( e );
@ -1398,7 +1397,7 @@ public final class SessionImpl
private void fireReplicate(ReplicateEvent event) {
checkOpen();
checkTransactionSynchStatus();
pulseTransactionCoordinator();
for ( ReplicateEventListener listener : listeners( EventType.REPLICATE ) ) {
listener.onReplicate( event );
}
@ -1419,7 +1418,7 @@ public final class SessionImpl
private void fireEvict(EvictEvent event) {
checkOpen();
checkTransactionSynchStatus();
pulseTransactionCoordinator();
for ( EvictEventListener listener : listeners( EventType.EVICT ) ) {
listener.onEvict( event );
}
@ -1446,7 +1445,7 @@ public final class SessionImpl
@Override
public boolean isDirty() throws HibernateException {
checkOpen();
checkTransactionSynchStatus();
pulseTransactionCoordinator();
log.debug( "Checking session dirtiness" );
if ( actionQueue.areInsertionsOrDeletionsQueued() ) {
log.debug( "Session dirty (scheduled updates and insertions)" );
@ -1468,7 +1467,7 @@ public final class SessionImpl
private void doFlush() {
checkTransactionNeededForUpdateOperation();
checkTransactionSynchStatus();
pulseTransactionCoordinator();
try {
if ( persistenceContext.getCascadeLevel() > 0 ) {
@ -1516,7 +1515,7 @@ public final class SessionImpl
@Override
public List list(String query, QueryParameters queryParameters) throws HibernateException {
checkOpenOrWaitingForAutoClose();
checkTransactionSynchStatus();
pulseTransactionCoordinator();
queryParameters.validateParameters();
HQLQueryPlan plan = queryParameters.getQueryPlan();
@ -1526,7 +1525,7 @@ public final class SessionImpl
autoFlushIfRequired( plan.getQuerySpaces() );
List results = Collections.EMPTY_LIST;
final List results;
boolean success = false;
dontFlushFromFind++; //stops flush being called multiple times if this method is recursively called
@ -1545,7 +1544,7 @@ public final class SessionImpl
@Override
public int executeUpdate(String query, QueryParameters queryParameters) throws HibernateException {
checkOpenOrWaitingForAutoClose();
checkTransactionSynchStatus();
pulseTransactionCoordinator();
queryParameters.validateParameters();
HQLQueryPlan plan = getQueryPlan( query, false );
autoFlushIfRequired( plan.getQuerySpaces() );
@ -1606,7 +1605,7 @@ public final class SessionImpl
NativeSQLQuerySpecification nativeQuerySpecification,
QueryParameters queryParameters) throws HibernateException {
checkOpenOrWaitingForAutoClose();
checkTransactionSynchStatus();
pulseTransactionCoordinator();
queryParameters.validateParameters();
NativeSQLQueryPlan plan = getNativeQueryPlan( nativeQuerySpecification );
@ -1629,7 +1628,7 @@ public final class SessionImpl
@Override
public Iterator iterate(String query, QueryParameters queryParameters) throws HibernateException {
checkOpenOrWaitingForAutoClose();
checkTransactionSynchStatus();
pulseTransactionCoordinator();
queryParameters.validateParameters();
HQLQueryPlan plan = queryParameters.getQueryPlan();
@ -1652,7 +1651,7 @@ public final class SessionImpl
@Override
public ScrollableResultsImplementor scroll(String query, QueryParameters queryParameters) throws HibernateException {
checkOpenOrWaitingForAutoClose();
checkTransactionSynchStatus();
pulseTransactionCoordinator();
HQLQueryPlan plan = queryParameters.getQueryPlan();
if ( plan == null ) {
@ -1674,7 +1673,7 @@ public final class SessionImpl
@Override
public org.hibernate.query.Query createFilter(Object collection, String queryString) {
checkOpen();
checkTransactionSynchStatus();
pulseTransactionCoordinator();
CollectionFilterImpl filter = new CollectionFilterImpl(
queryString,
collection,
@ -1698,7 +1697,7 @@ public final class SessionImpl
@Override
public Object instantiate(EntityPersister persister, Serializable id) throws HibernateException {
checkOpenOrWaitingForAutoClose();
checkTransactionSynchStatus();
pulseTransactionCoordinator();
Object result = getInterceptor().instantiate(
persister.getEntityName(),
persister.getEntityMetamodel().getEntityMode(),
@ -1851,7 +1850,7 @@ public final class SessionImpl
@Override
public List listFilter(Object collection, String filter, QueryParameters queryParameters) {
checkOpenOrWaitingForAutoClose();
checkTransactionSynchStatus();
pulseTransactionCoordinator();
FilterQueryPlan plan = getFilterQueryPlan( collection, filter, queryParameters, false );
List results = Collections.EMPTY_LIST;
@ -1872,7 +1871,7 @@ public final class SessionImpl
@Override
public Iterator iterateFilter(Object collection, String filter, QueryParameters queryParameters) {
checkOpenOrWaitingForAutoClose();
checkTransactionSynchStatus();
pulseTransactionCoordinator();
FilterQueryPlan plan = getFilterQueryPlan( collection, filter, queryParameters, true );
Iterator itr = plan.performIterate( queryParameters, this );
delayedAfterCompletion();
@ -1917,7 +1916,7 @@ public final class SessionImpl
CriteriaImpl criteriaImpl = (CriteriaImpl) criteria;
checkOpenOrWaitingForAutoClose();
checkTransactionSynchStatus();
pulseTransactionCoordinator();
String entityName = criteriaImpl.getEntityOrClassName();
CriteriaLoader loader = new CriteriaLoader(
@ -2070,7 +2069,7 @@ public final class SessionImpl
@Override
public boolean contains(Object object) {
checkOpen();
checkTransactionSynchStatus();
pulseTransactionCoordinator();
if ( object == null ) {
return false;
@ -2134,7 +2133,7 @@ public final class SessionImpl
@Override
public boolean contains(String entityName, Object object) {
checkOpenOrWaitingForAutoClose();
checkTransactionSynchStatus();
pulseTransactionCoordinator();
if ( object == null ) {
return false;
@ -2266,7 +2265,7 @@ public final class SessionImpl
@Override
public void initializeCollection(PersistentCollection collection, boolean writing) {
checkOpenOrWaitingForAutoClose();
checkTransactionSynchStatus();
pulseTransactionCoordinator();
InitializeCollectionEvent event = new InitializeCollectionEvent( collection, this );
for ( InitializeCollectionEventListener listener : listeners( EventType.INIT_COLLECTION ) ) {
listener.onInitializeCollection( event );
@ -2373,13 +2372,13 @@ public final class SessionImpl
@Override
public SessionStatistics getStatistics() {
checkTransactionSynchStatus();
pulseTransactionCoordinator();
return new SessionStatisticsImpl( this );
}
@Override
public boolean isEventSource() {
checkTransactionSynchStatus();
pulseTransactionCoordinator();
return true;
}
@ -2448,21 +2447,21 @@ public final class SessionImpl
@Override
public Filter getEnabledFilter(String filterName) {
checkTransactionSynchStatus();
pulseTransactionCoordinator();
return loadQueryInfluencers.getEnabledFilter( filterName );
}
@Override
public Filter enableFilter(String filterName) {
checkOpen();
checkTransactionSynchStatus();
pulseTransactionCoordinator();
return loadQueryInfluencers.enableFilter( filterName );
}
@Override
public void disableFilter(String filterName) {
checkOpen();
checkTransactionSynchStatus();
pulseTransactionCoordinator();
loadQueryInfluencers.disableFilter( filterName );
}