HHH-16982 Avoid unnecessary registerReloadedEntity calls
This commit is contained in:
parent
7915ad635a
commit
b9e5d3a6bc
|
@ -37,6 +37,11 @@ public class DelegatingDomainQueryExecutionContext implements DomainQueryExecuti
|
||||||
return delegate.getCallback();
|
return delegate.getCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasCallbackActions() {
|
||||||
|
return delegate.hasCallbackActions();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SharedSessionContractImplementor getSession() {
|
public SharedSessionContractImplementor getSession() {
|
||||||
return delegate.getSession();
|
return delegate.getSession();
|
||||||
|
|
|
@ -621,6 +621,11 @@ public abstract class AbstractSelectionQuery<R>
|
||||||
return callback;
|
return callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasCallbackActions() {
|
||||||
|
return callback != null && callback.hasAfterLoadActions();
|
||||||
|
}
|
||||||
|
|
||||||
protected void resetCallback() {
|
protected void resetCallback() {
|
||||||
callback = null;
|
callback = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,11 @@ public interface DomainQueryExecutionContext {
|
||||||
*/
|
*/
|
||||||
Callback getCallback();
|
Callback getCallback();
|
||||||
|
|
||||||
|
default boolean hasCallbackActions() {
|
||||||
|
final Callback callback = getCallback();
|
||||||
|
return callback != null && callback.hasAfterLoadActions();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The underlying session
|
* The underlying session
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -433,6 +433,11 @@ public class NativeQueryImpl<R>
|
||||||
return callback;
|
return callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasCallbackActions() {
|
||||||
|
return callback != null && callback.hasAfterLoadActions();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryParameterBindings getQueryParameterBindings() {
|
public QueryParameterBindings getQueryParameterBindings() {
|
||||||
return parameterBindings;
|
return parameterBindings;
|
||||||
|
|
|
@ -65,6 +65,11 @@ public class SqmJdbcExecutionContextAdapter extends BaseExecutionContext {
|
||||||
return sqmExecutionContext.getCallback();
|
return sqmExecutionContext.getCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasCallbackActions() {
|
||||||
|
return sqmExecutionContext.hasCallbackActions();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasQueryExecutionToBeAddedToStatistics() {
|
public boolean hasQueryExecutionToBeAddedToStatistics() {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -37,4 +37,9 @@ public class CallbackImpl implements Callback {
|
||||||
afterLoadActions.get( i ).afterLoad( entity, entityMappingType, session );
|
afterLoadActions.get( i ).afterLoad( entity, entityMappingType, session );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasAfterLoadActions() {
|
||||||
|
return !afterLoadActions.isEmpty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,4 +29,9 @@ public class CallbackNoOp implements Callback {
|
||||||
public void invokeAfterLoadActions(Object entity, EntityMappingType entityMappingType, SharedSessionContractImplementor session) {
|
public void invokeAfterLoadActions(Object entity, EntityMappingType entityMappingType, SharedSessionContractImplementor session) {
|
||||||
// don't do anything
|
// don't do anything
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasAfterLoadActions() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -798,6 +798,11 @@ public class JdbcSelectExecutorStandardImpl implements JdbcSelectExecutor {
|
||||||
return context.getCallback();
|
return context.getCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasCallbackActions() {
|
||||||
|
return context.hasCallbackActions();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getEnabledFetchProfiles() {
|
public Set<String> getEnabledFetchProfiles() {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -36,4 +36,6 @@ public interface Callback {
|
||||||
default void invokeAfterLoadActions(SharedSessionContractImplementor session, Object entity, org.hibernate.persister.entity.Loadable persister) {
|
default void invokeAfterLoadActions(SharedSessionContractImplementor session, Object entity, org.hibernate.persister.entity.Loadable persister) {
|
||||||
invokeAfterLoadActions( entity, persister, session );
|
invokeAfterLoadActions( entity, persister, session );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean hasAfterLoadActions();
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,11 @@ public interface ExecutionContext {
|
||||||
|
|
||||||
Callback getCallback();
|
Callback getCallback();
|
||||||
|
|
||||||
|
default boolean hasCallbackActions() {
|
||||||
|
final Callback callback = getCallback();
|
||||||
|
return callback != null && callback.hasAfterLoadActions();
|
||||||
|
}
|
||||||
|
|
||||||
String getQueryIdentifier(String sql);
|
String getQueryIdentifier(String sql);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -105,6 +105,11 @@ public class NestedRowProcessingState extends BaseExecutionContext implements Ro
|
||||||
return processingState.getCallback();
|
return processingState.getCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasCallbackActions() {
|
||||||
|
return processingState.hasCallbackActions();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CollectionKey getCollectionKey() {
|
public CollectionKey getCollectionKey() {
|
||||||
return processingState.getCollectionKey();
|
return processingState.getCollectionKey();
|
||||||
|
|
|
@ -60,7 +60,6 @@ import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingOptions;
|
||||||
import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingState;
|
import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingState;
|
||||||
import org.hibernate.sql.results.jdbc.spi.RowProcessingState;
|
import org.hibernate.sql.results.jdbc.spi.RowProcessingState;
|
||||||
import org.hibernate.stat.spi.StatisticsImplementor;
|
import org.hibernate.stat.spi.StatisticsImplementor;
|
||||||
import org.hibernate.type.AssociationType;
|
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
|
|
||||||
import static org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer.UNFETCHED_PROPERTY;
|
import static org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer.UNFETCHED_PROPERTY;
|
||||||
|
@ -717,7 +716,7 @@ public abstract class AbstractEntityInitializer extends AbstractFetchParentAcces
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void registerReloadedEntity(RowProcessingState rowProcessingState, Object instance) {
|
protected void registerReloadedEntity(RowProcessingState rowProcessingState, Object instance) {
|
||||||
if ( rowProcessingState.getCallback() != null ) {
|
if ( rowProcessingState.hasCallbackActions() ) {
|
||||||
// This is only needed for follow-on locking, so skip registering the entity if there is no callback
|
// This is only needed for follow-on locking, so skip registering the entity if there is no callback
|
||||||
rowProcessingState.getJdbcValuesSourceProcessingState()
|
rowProcessingState.getJdbcValuesSourceProcessingState()
|
||||||
.registerReloadedEntity(
|
.registerReloadedEntity(
|
||||||
|
|
|
@ -153,6 +153,11 @@ public class RowProcessingStateStandardImpl extends BaseExecutionContext impleme
|
||||||
return executionContext.getCallback();
|
return executionContext.getCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasCallbackActions() {
|
||||||
|
return executionContext.hasCallbackActions();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CollectionKey getCollectionKey() {
|
public CollectionKey getCollectionKey() {
|
||||||
return executionContext.getCollectionKey();
|
return executionContext.getCollectionKey();
|
||||||
|
|
|
@ -55,6 +55,11 @@ public abstract class BaseSqmUnitTest
|
||||||
public void invokeAfterLoadActions(Object entity, EntityMappingType entityMappingType, SharedSessionContractImplementor session) {
|
public void invokeAfterLoadActions(Object entity, EntityMappingType entityMappingType, SharedSessionContractImplementor session) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasAfterLoadActions() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
protected SqmSelectStatement<?> interpretSelect(String hql) {
|
protected SqmSelectStatement<?> interpretSelect(String hql) {
|
||||||
return interpretSelect( hql, sessionFactory() );
|
return interpretSelect( hql, sessionFactory() );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue