HHH-16559 Disable batch fetching for dynamic instantiation queries
This commit is contained in:
parent
2cd7104d9d
commit
a64490ed50
|
@ -18,11 +18,14 @@ import org.hibernate.sql.exec.spi.ExecutionContext;
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public interface AssemblerCreationState {
|
public interface AssemblerCreationState {
|
||||||
|
|
||||||
default boolean isScrollResult() {
|
default boolean isScrollResult() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default boolean isDynamicInstantiation() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
LockMode determineEffectiveLockMode(String identificationVariable);
|
LockMode determineEffectiveLockMode(String identificationVariable);
|
||||||
|
|
||||||
Initializer resolveInitializer(
|
Initializer resolveInitializer(
|
||||||
|
|
|
@ -94,6 +94,9 @@ public class EntitySelectFetchInitializerBuilder {
|
||||||
.effectivelyBatchLoadable( entityPersister ) ) {
|
.effectivelyBatchLoadable( entityPersister ) ) {
|
||||||
return NONE;
|
return NONE;
|
||||||
}
|
}
|
||||||
|
else if ( creationState.isDynamicInstantiation() ) {
|
||||||
|
return BatchMode.BATCH_INITIALIZE;
|
||||||
|
}
|
||||||
while ( parentAccess.isEmbeddableInitializer() ) {
|
while ( parentAccess.isEmbeddableInitializer() ) {
|
||||||
final EmbeddableInitializer embeddableInitializer = parentAccess.asEmbeddableInitializer();
|
final EmbeddableInitializer embeddableInitializer = parentAccess.asEmbeddableInitializer();
|
||||||
final EmbeddableValuedModelPart initializedPart = embeddableInitializer.getInitializedPart();
|
final EmbeddableValuedModelPart initializedPart = embeddableInitializer.getInitializedPart();
|
||||||
|
|
|
@ -6,14 +6,12 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.sql.results.internal;
|
package org.hibernate.sql.results.internal;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import org.hibernate.CacheMode;
|
import org.hibernate.CacheMode;
|
||||||
import org.hibernate.HibernateException;
|
|
||||||
import org.hibernate.LockMode;
|
import org.hibernate.LockMode;
|
||||||
import org.hibernate.LockOptions;
|
import org.hibernate.LockOptions;
|
||||||
import org.hibernate.cache.spi.access.CollectionDataAccess;
|
import org.hibernate.cache.spi.access.CollectionDataAccess;
|
||||||
|
@ -28,7 +26,6 @@ import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.internal.CoreLogging;
|
import org.hibernate.internal.CoreLogging;
|
||||||
import org.hibernate.internal.CoreMessageLogger;
|
import org.hibernate.internal.CoreMessageLogger;
|
||||||
import org.hibernate.metamodel.mapping.JdbcMapping;
|
|
||||||
import org.hibernate.metamodel.mapping.ModelPart;
|
import org.hibernate.metamodel.mapping.ModelPart;
|
||||||
import org.hibernate.metamodel.mapping.PluralAttributeMapping;
|
import org.hibernate.metamodel.mapping.PluralAttributeMapping;
|
||||||
import org.hibernate.persister.collection.CollectionPersister;
|
import org.hibernate.persister.collection.CollectionPersister;
|
||||||
|
@ -42,6 +39,7 @@ import org.hibernate.sql.results.ResultsLogger;
|
||||||
import org.hibernate.sql.results.graph.AssemblerCreationState;
|
import org.hibernate.sql.results.graph.AssemblerCreationState;
|
||||||
import org.hibernate.sql.results.graph.DomainResultAssembler;
|
import org.hibernate.sql.results.graph.DomainResultAssembler;
|
||||||
import org.hibernate.sql.results.graph.Initializer;
|
import org.hibernate.sql.results.graph.Initializer;
|
||||||
|
import org.hibernate.sql.results.graph.instantiation.DynamicInstantiationResult;
|
||||||
import org.hibernate.sql.results.jdbc.spi.JdbcValues;
|
import org.hibernate.sql.results.jdbc.spi.JdbcValues;
|
||||||
import org.hibernate.sql.results.jdbc.spi.JdbcValuesMapping;
|
import org.hibernate.sql.results.jdbc.spi.JdbcValuesMapping;
|
||||||
import org.hibernate.sql.results.spi.RowReader;
|
import org.hibernate.sql.results.spi.RowReader;
|
||||||
|
@ -77,12 +75,23 @@ public class ResultsHelper {
|
||||||
|
|
||||||
final List<DomainResultAssembler<?>> assemblers = jdbcValuesMapping.resolveAssemblers(
|
final List<DomainResultAssembler<?>> assemblers = jdbcValuesMapping.resolveAssemblers(
|
||||||
new AssemblerCreationState() {
|
new AssemblerCreationState() {
|
||||||
|
Boolean dynamicInstantiation;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isScrollResult() {
|
public boolean isScrollResult() {
|
||||||
return executionContext.isScrollResult();
|
return executionContext.isScrollResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDynamicInstantiation() {
|
||||||
|
if ( dynamicInstantiation == null ) {
|
||||||
|
dynamicInstantiation = jdbcValuesMapping.getDomainResults()
|
||||||
|
.stream()
|
||||||
|
.anyMatch( domainResult -> domainResult instanceof DynamicInstantiationResult );
|
||||||
|
}
|
||||||
|
return dynamicInstantiation;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LockMode determineEffectiveLockMode(String identificationVariable) {
|
public LockMode determineEffectiveLockMode(String identificationVariable) {
|
||||||
return lockOptions.getEffectiveLockMode( identificationVariable );
|
return lockOptions.getEffectiveLockMode( identificationVariable );
|
||||||
|
|
Loading…
Reference in New Issue