HHH-14607 prefer FetchOptions over FetchStrategy
This commit is contained in:
parent
b2bdcf9778
commit
f90a5f930b
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.engine;
|
||||
|
||||
import org.hibernate.sql.results.graph.FetchOptions;
|
||||
|
||||
/**
|
||||
* Describes the strategy for fetching an association, which includes both when and how.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class FetchStrategy implements FetchOptions {
|
||||
public static FetchStrategy IMMEDIATE_JOIN = new FetchStrategy( FetchTiming.IMMEDIATE, FetchStyle.JOIN );
|
||||
|
||||
private final FetchTiming timing;
|
||||
private final FetchStyle style;
|
||||
|
||||
/**
|
||||
* Constructs a FetchStrategy.
|
||||
*
|
||||
* @param timing The fetch timing (the when)
|
||||
* @param style The fetch style (the how).
|
||||
*/
|
||||
public FetchStrategy(FetchTiming timing, FetchStyle style) {
|
||||
this.timing = timing;
|
||||
this.style = style;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchTiming getTiming() {
|
||||
return timing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchStyle getStyle() {
|
||||
return style;
|
||||
}
|
||||
}
|
|
@ -83,7 +83,6 @@ import org.hibernate.sql.results.graph.entity.EntityResultGraphNode;
|
|||
import org.hibernate.sql.results.graph.entity.EntityValuedFetchable;
|
||||
import org.hibernate.sql.results.internal.SqlSelectionImpl;
|
||||
import org.hibernate.sql.results.internal.StandardEntityGraphTraversalStateImpl;
|
||||
import org.hibernate.tuple.entity.EntityMetamodel;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
|
@ -716,7 +715,7 @@ public class LoaderSelectBuilder {
|
|||
// 'entity graph' takes precedence over 'fetch profile'
|
||||
if ( entityGraphTraversalState != null ) {
|
||||
traversalResult = entityGraphTraversalState.traverse( fetchParent, fetchable, isKeyFetchable );
|
||||
fetchTiming = traversalResult.getFetchStrategy();
|
||||
fetchTiming = traversalResult.getFetchTiming();
|
||||
joined = traversalResult.isJoined();
|
||||
}
|
||||
else if ( loadQueryInfluencers.hasEnabledFetchProfiles() ) {
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
*/
|
||||
package org.hibernate.metamodel.mapping.internal;
|
||||
|
||||
import org.hibernate.engine.FetchStrategy;
|
||||
import org.hibernate.engine.FetchStyle;
|
||||
import org.hibernate.engine.FetchTiming;
|
||||
import org.hibernate.metamodel.mapping.ManagedMappingType;
|
||||
import org.hibernate.metamodel.mapping.SingularAttributeMapping;
|
||||
import org.hibernate.metamodel.mapping.StateArrayContributorMetadataAccess;
|
||||
|
@ -26,10 +27,22 @@ public abstract class AbstractSingularAttributeMapping
|
|||
String name,
|
||||
int stateArrayPosition,
|
||||
StateArrayContributorMetadataAccess attributeMetadataAccess,
|
||||
FetchOptions mappedFetchStrategy,
|
||||
FetchOptions mappedFetchOptions,
|
||||
ManagedMappingType declaringType,
|
||||
PropertyAccess propertyAccess) {
|
||||
super( name, attributeMetadataAccess, mappedFetchStrategy, stateArrayPosition, declaringType );
|
||||
super( name, attributeMetadataAccess, mappedFetchOptions, stateArrayPosition, declaringType );
|
||||
this.propertyAccess = propertyAccess;
|
||||
}
|
||||
|
||||
public AbstractSingularAttributeMapping(
|
||||
String name,
|
||||
int stateArrayPosition,
|
||||
StateArrayContributorMetadataAccess attributeMetadataAccess,
|
||||
FetchTiming fetchTiming,
|
||||
FetchStyle fetchStyle,
|
||||
ManagedMappingType declaringType,
|
||||
PropertyAccess propertyAccess) {
|
||||
super( name, attributeMetadataAccess, fetchTiming, fetchStyle, stateArrayPosition, declaringType );
|
||||
this.propertyAccess = propertyAccess;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,14 +43,14 @@ public abstract class AbstractStateArrayContributorMapping
|
|||
public AbstractStateArrayContributorMapping(
|
||||
String name,
|
||||
StateArrayContributorMetadataAccess attributeMetadataAccess,
|
||||
FetchOptions mappedFetchStrategy,
|
||||
FetchOptions mappedFetchOptions,
|
||||
int stateArrayPosition,
|
||||
ManagedMappingType declaringType) {
|
||||
this(
|
||||
name,
|
||||
attributeMetadataAccess,
|
||||
mappedFetchStrategy.getTiming(),
|
||||
mappedFetchStrategy.getStyle(),
|
||||
mappedFetchOptions.getTiming(),
|
||||
mappedFetchOptions.getStyle(),
|
||||
stateArrayPosition,
|
||||
declaringType
|
||||
);
|
||||
|
|
|
@ -9,7 +9,7 @@ package org.hibernate.metamodel.mapping.internal;
|
|||
import java.util.function.BiConsumer;
|
||||
|
||||
import org.hibernate.LockMode;
|
||||
import org.hibernate.engine.FetchStrategy;
|
||||
import org.hibernate.engine.FetchStyle;
|
||||
import org.hibernate.engine.FetchTiming;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.mapping.IndexedConsumer;
|
||||
|
@ -67,7 +67,8 @@ public class BasicAttributeMapping
|
|||
NavigableRole navigableRole,
|
||||
int stateArrayPosition,
|
||||
StateArrayContributorMetadataAccess attributeMetadataAccess,
|
||||
FetchStrategy mappedFetchStrategy,
|
||||
FetchTiming mappedFetchTiming,
|
||||
FetchStyle mappedFetchStyle,
|
||||
String tableExpression,
|
||||
String mappedColumnExpression,
|
||||
boolean isFormula,
|
||||
|
@ -77,7 +78,7 @@ public class BasicAttributeMapping
|
|||
JdbcMapping jdbcMapping,
|
||||
ManagedMappingType declaringType,
|
||||
PropertyAccess propertyAccess) {
|
||||
super( attributeName, stateArrayPosition, attributeMetadataAccess, mappedFetchStrategy, declaringType, propertyAccess );
|
||||
super( attributeName, stateArrayPosition, attributeMetadataAccess, mappedFetchTiming, mappedFetchStyle, declaringType, propertyAccess );
|
||||
this.navigableRole = navigableRole;
|
||||
this.tableExpression = tableExpression;
|
||||
this.mappedColumnExpression = mappedColumnExpression;
|
||||
|
@ -134,7 +135,8 @@ public class BasicAttributeMapping
|
|||
original.getNavigableRole(),
|
||||
stateArrayPosition,
|
||||
attributeMetadataAccess,
|
||||
FetchStrategy.IMMEDIATE_JOIN,
|
||||
FetchTiming.IMMEDIATE,
|
||||
FetchStyle.JOIN,
|
||||
selectableMapping.getContainingTableExpression(),
|
||||
selectableMapping.getSelectionExpression(),
|
||||
selectableMapping.isFormula(),
|
||||
|
|
|
@ -13,10 +13,8 @@ import java.util.function.Consumer;
|
|||
import org.hibernate.LockMode;
|
||||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
import org.hibernate.SharedSessionContract;
|
||||
import org.hibernate.engine.FetchStrategy;
|
||||
import org.hibernate.engine.FetchStyle;
|
||||
import org.hibernate.engine.FetchTiming;
|
||||
import org.hibernate.engine.internal.ForeignKeys;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.mapping.Any;
|
||||
import org.hibernate.mapping.IndexedConsumer;
|
||||
|
@ -75,9 +73,8 @@ public class DiscriminatedAssociationAttributeMapping
|
|||
bootProperty.getName(),
|
||||
stateArrayPosition,
|
||||
attributeMetadataAccess,
|
||||
fetchTiming == FetchTiming.IMMEDIATE
|
||||
? new FetchStrategy( FetchTiming.IMMEDIATE, FetchStyle.SELECT )
|
||||
: new FetchStrategy( FetchTiming.DELAYED, FetchStyle.SELECT ),
|
||||
fetchTiming,
|
||||
FetchStyle.SELECT,
|
||||
declaringType,
|
||||
propertyAccess
|
||||
);
|
||||
|
|
|
@ -11,7 +11,7 @@ import java.util.function.BiConsumer;
|
|||
import java.util.function.Consumer;
|
||||
|
||||
import org.hibernate.LockMode;
|
||||
import org.hibernate.engine.FetchStrategy;
|
||||
import org.hibernate.engine.FetchStyle;
|
||||
import org.hibernate.engine.FetchTiming;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||
|
@ -72,7 +72,8 @@ public class EmbeddedAttributeMapping
|
|||
String tableExpression,
|
||||
StateArrayContributorMetadataAccess attributeMetadataAccess,
|
||||
String parentInjectionAttributeName,
|
||||
FetchStrategy mappedFetchStrategy,
|
||||
FetchTiming mappedFetchTiming,
|
||||
FetchStyle mappedFetchStyle,
|
||||
EmbeddableMappingType embeddableMappingType,
|
||||
ManagedMappingType declaringType,
|
||||
PropertyAccess propertyAccess) {
|
||||
|
@ -80,7 +81,8 @@ public class EmbeddedAttributeMapping
|
|||
name,
|
||||
stateArrayPosition,
|
||||
attributeMetadataAccess,
|
||||
mappedFetchStrategy,
|
||||
mappedFetchTiming,
|
||||
mappedFetchStyle,
|
||||
declaringType,
|
||||
propertyAccess
|
||||
);
|
||||
|
|
|
@ -26,7 +26,6 @@ import org.hibernate.collection.internal.StandardIdentifierBagSemantics;
|
|||
import org.hibernate.collection.internal.StandardListSemantics;
|
||||
import org.hibernate.collection.spi.CollectionSemantics;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.engine.FetchStrategy;
|
||||
import org.hibernate.engine.FetchStyle;
|
||||
import org.hibernate.engine.FetchTiming;
|
||||
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
|
||||
|
@ -79,7 +78,7 @@ import org.hibernate.persister.collection.CollectionPersister;
|
|||
import org.hibernate.persister.collection.SQLLoadableCollection;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.persister.entity.Joinable;
|
||||
import org.hibernate.persister.walking.internal.FetchStrategyHelper;
|
||||
import org.hibernate.persister.walking.internal.FetchOptionsHelper;
|
||||
import org.hibernate.property.access.internal.PropertyAccessStrategyMapImpl;
|
||||
import org.hibernate.property.access.spi.PropertyAccess;
|
||||
import org.hibernate.sql.ast.spi.SqlAliasStemHelper;
|
||||
|
@ -347,9 +346,8 @@ public class MappingModelCreationHelper {
|
|||
}
|
||||
};
|
||||
|
||||
final FetchStrategy fetchStrategy = bootProperty.isLazy()
|
||||
? new FetchStrategy( FetchTiming.DELAYED, FetchStyle.SELECT )
|
||||
: FetchStrategy.IMMEDIATE_JOIN;
|
||||
final FetchTiming fetchTiming = bootProperty.isLazy() ? FetchTiming.DELAYED : FetchTiming.IMMEDIATE;
|
||||
final FetchStyle fetchStyle = bootProperty.isLazy() ? FetchStyle.SELECT : FetchStyle.JOIN;
|
||||
|
||||
if ( valueConverter != null ) {
|
||||
|
||||
|
@ -379,7 +377,8 @@ public class MappingModelCreationHelper {
|
|||
navigableRole,
|
||||
stateArrayPosition,
|
||||
attributeMetadataAccess,
|
||||
fetchStrategy,
|
||||
fetchTiming,
|
||||
fetchStyle,
|
||||
tableExpression,
|
||||
attrColumnName,
|
||||
false,
|
||||
|
@ -397,7 +396,8 @@ public class MappingModelCreationHelper {
|
|||
navigableRole,
|
||||
stateArrayPosition,
|
||||
attributeMetadataAccess,
|
||||
fetchStrategy,
|
||||
fetchTiming,
|
||||
fetchStyle,
|
||||
tableExpression,
|
||||
attrColumnName,
|
||||
isAttrFormula,
|
||||
|
@ -444,7 +444,8 @@ public class MappingModelCreationHelper {
|
|||
tableExpression,
|
||||
attributeMetadataAccess,
|
||||
component.getParentProperty(),
|
||||
FetchStrategy.IMMEDIATE_JOIN,
|
||||
FetchTiming.IMMEDIATE,
|
||||
FetchStyle.JOIN,
|
||||
attributeMappingType,
|
||||
declaringType,
|
||||
propertyAccess
|
||||
|
@ -807,12 +808,18 @@ public class MappingModelCreationHelper {
|
|||
}
|
||||
};
|
||||
|
||||
final FetchStyle style = FetchStrategyHelper.determineFetchStyleByMetadata(
|
||||
final FetchStyle style = FetchOptionsHelper.determineFetchStyleByMetadata(
|
||||
fetchMode,
|
||||
collectionDescriptor.getCollectionType(),
|
||||
sessionFactory
|
||||
);
|
||||
|
||||
final FetchTiming timing = FetchOptionsHelper.determineFetchTiming(
|
||||
style,
|
||||
collectionDescriptor.getCollectionType(),
|
||||
sessionFactory
|
||||
);
|
||||
|
||||
final PluralAttributeMappingImpl pluralAttributeMapping = new PluralAttributeMappingImpl(
|
||||
attrName,
|
||||
bootValueMapping,
|
||||
|
@ -823,14 +830,8 @@ public class MappingModelCreationHelper {
|
|||
elementDescriptor,
|
||||
indexDescriptor,
|
||||
identifierDescriptor,
|
||||
new FetchStrategy(
|
||||
FetchStrategyHelper.determineFetchTiming(
|
||||
style,
|
||||
collectionDescriptor.getCollectionType(),
|
||||
sessionFactory
|
||||
),
|
||||
style
|
||||
),
|
||||
timing,
|
||||
style,
|
||||
cascadeStyle,
|
||||
declaringType,
|
||||
collectionDescriptor
|
||||
|
@ -1488,7 +1489,7 @@ public class MappingModelCreationHelper {
|
|||
SessionFactoryImplementor sessionFactory = creationProcess.getCreationContext().getSessionFactory();
|
||||
|
||||
final AssociationType type = (AssociationType) bootProperty.getType();
|
||||
final FetchStyle fetchStyle = FetchStrategyHelper
|
||||
final FetchStyle fetchStyle = FetchOptionsHelper
|
||||
.determineFetchStyleByMetadata(
|
||||
bootProperty.getValue().getFetchMode(),
|
||||
type,
|
||||
|
@ -1503,18 +1504,17 @@ public class MappingModelCreationHelper {
|
|||
fetchTiming = FetchTiming.IMMEDIATE;
|
||||
}
|
||||
else {
|
||||
fetchTiming = FetchStrategyHelper.determineFetchTiming( fetchStyle, type, sessionFactory );
|
||||
fetchTiming = FetchOptionsHelper.determineFetchTiming( fetchStyle, type, sessionFactory );
|
||||
}
|
||||
|
||||
final FetchStrategy fetchStrategy = new FetchStrategy( fetchTiming, fetchStyle );
|
||||
|
||||
final ToOneAttributeMapping attributeMapping = new ToOneAttributeMapping(
|
||||
attrName,
|
||||
navigableRole,
|
||||
stateArrayPosition,
|
||||
(ToOne) bootProperty.getValue(),
|
||||
stateArrayContributorMetadataAccess,
|
||||
fetchStrategy,
|
||||
fetchTiming,
|
||||
fetchStyle,
|
||||
entityPersister,
|
||||
declaringType,
|
||||
declaringEntityPersister,
|
||||
|
|
|
@ -15,7 +15,6 @@ import java.util.function.Supplier;
|
|||
import org.hibernate.LockMode;
|
||||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.engine.FetchStrategy;
|
||||
import org.hibernate.engine.FetchStyle;
|
||||
import org.hibernate.engine.FetchTiming;
|
||||
import org.hibernate.engine.spi.CascadeStyle;
|
||||
|
@ -131,7 +130,7 @@ public class PluralAttributeMappingImpl
|
|||
CollectionPart elementDescriptor,
|
||||
CollectionPart indexDescriptor,
|
||||
CollectionIdentifierDescriptor identifierDescriptor,
|
||||
FetchStrategy fetchStrategy,
|
||||
FetchOptions fetchOptions,
|
||||
CascadeStyle cascadeStyle,
|
||||
ManagedMappingType declaringType,
|
||||
CollectionPersister collectionDescriptor) {
|
||||
|
@ -145,8 +144,8 @@ public class PluralAttributeMappingImpl
|
|||
elementDescriptor,
|
||||
indexDescriptor,
|
||||
identifierDescriptor,
|
||||
fetchStrategy.getTiming(),
|
||||
fetchStrategy.getStyle(),
|
||||
fetchOptions.getTiming(),
|
||||
fetchOptions.getStyle(),
|
||||
cascadeStyle,
|
||||
declaringType,
|
||||
collectionDescriptor
|
||||
|
|
|
@ -11,7 +11,7 @@ import java.util.HashSet;
|
|||
import java.util.Set;
|
||||
|
||||
import org.hibernate.LockMode;
|
||||
import org.hibernate.engine.FetchStrategy;
|
||||
import org.hibernate.engine.FetchStyle;
|
||||
import org.hibernate.engine.FetchTiming;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
|
@ -55,6 +55,7 @@ import org.hibernate.sql.ast.tree.from.TableReference;
|
|||
import org.hibernate.sql.results.graph.DomainResult;
|
||||
import org.hibernate.sql.results.graph.DomainResultCreationState;
|
||||
import org.hibernate.sql.results.graph.Fetch;
|
||||
import org.hibernate.sql.results.graph.FetchOptions;
|
||||
import org.hibernate.sql.results.graph.FetchParent;
|
||||
import org.hibernate.sql.results.graph.embeddable.EmbeddableValuedFetchable;
|
||||
import org.hibernate.sql.results.graph.entity.EntityFetch;
|
||||
|
@ -109,7 +110,34 @@ public class ToOneAttributeMapping
|
|||
int stateArrayPosition,
|
||||
ToOne bootValue,
|
||||
StateArrayContributorMetadataAccess attributeMetadataAccess,
|
||||
FetchStrategy mappedFetchStrategy,
|
||||
FetchOptions mappedFetchOptions,
|
||||
EntityMappingType entityMappingType,
|
||||
ManagedMappingType declaringType,
|
||||
EntityPersister declaringEntityPersister,
|
||||
PropertyAccess propertyAccess) {
|
||||
this(
|
||||
name,
|
||||
navigableRole,
|
||||
stateArrayPosition,
|
||||
bootValue,
|
||||
attributeMetadataAccess,
|
||||
mappedFetchOptions.getTiming(),
|
||||
mappedFetchOptions.getStyle(),
|
||||
entityMappingType,
|
||||
declaringType,
|
||||
declaringEntityPersister,
|
||||
propertyAccess
|
||||
);
|
||||
}
|
||||
|
||||
public ToOneAttributeMapping(
|
||||
String name,
|
||||
NavigableRole navigableRole,
|
||||
int stateArrayPosition,
|
||||
ToOne bootValue,
|
||||
StateArrayContributorMetadataAccess attributeMetadataAccess,
|
||||
FetchTiming mappedFetchTiming,
|
||||
FetchStyle mappedFetchStyle,
|
||||
EntityMappingType entityMappingType,
|
||||
ManagedMappingType declaringType,
|
||||
EntityPersister declaringEntityPersister,
|
||||
|
@ -118,7 +146,8 @@ public class ToOneAttributeMapping
|
|||
name,
|
||||
stateArrayPosition,
|
||||
attributeMetadataAccess,
|
||||
mappedFetchStrategy,
|
||||
mappedFetchTiming,
|
||||
mappedFetchStyle,
|
||||
declaringType,
|
||||
propertyAccess
|
||||
);
|
||||
|
|
|
@ -9,8 +9,8 @@ package org.hibernate.persister.walking.internal;
|
|||
import java.util.Iterator;
|
||||
|
||||
import org.hibernate.FetchMode;
|
||||
import org.hibernate.engine.FetchStrategy;
|
||||
import org.hibernate.engine.FetchStyle;
|
||||
import org.hibernate.engine.FetchTiming;
|
||||
import org.hibernate.engine.spi.CascadeStyle;
|
||||
import org.hibernate.engine.spi.CascadeStyles;
|
||||
import org.hibernate.engine.spi.LoadQueryInfluencers;
|
||||
|
@ -31,6 +31,7 @@ import org.hibernate.persister.walking.spi.CompositeCollectionElementDefinition;
|
|||
import org.hibernate.persister.walking.spi.CompositionDefinition;
|
||||
import org.hibernate.persister.walking.spi.EntityDefinition;
|
||||
import org.hibernate.persister.walking.spi.WalkingException;
|
||||
import org.hibernate.sql.results.graph.FetchOptions;
|
||||
import org.hibernate.type.AnyType;
|
||||
import org.hibernate.type.AssociationType;
|
||||
import org.hibernate.type.CompositeType;
|
||||
|
@ -182,20 +183,18 @@ public final class CompositionSingularSubAttributesHelper {
|
|||
}
|
||||
|
||||
@Override
|
||||
public FetchStrategy determineFetchPlan(LoadQueryInfluencers loadQueryInfluencers, PropertyPath propertyPath) {
|
||||
final FetchStyle style = FetchStrategyHelper.determineFetchStyleByMetadata(
|
||||
public FetchOptions determineFetchPlan(LoadQueryInfluencers loadQueryInfluencers, PropertyPath propertyPath) {
|
||||
final FetchStyle style = FetchOptionsHelper.determineFetchStyleByMetadata(
|
||||
fetchMode,
|
||||
(AssociationType) type,
|
||||
ownerEntityPersister.getFactory()
|
||||
);
|
||||
return new FetchStrategy(
|
||||
FetchStrategyHelper.determineFetchTiming(
|
||||
style,
|
||||
getType(),
|
||||
ownerEntityPersister.getFactory()
|
||||
),
|
||||
style
|
||||
final FetchTiming timing = FetchOptionsHelper.determineFetchTiming(
|
||||
style,
|
||||
getType(),
|
||||
ownerEntityPersister.getFactory()
|
||||
);
|
||||
return FetchOptions.valueOf( timing, style );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
package org.hibernate.persister.walking.internal;
|
||||
|
||||
import org.hibernate.FetchMode;
|
||||
import org.hibernate.engine.FetchStrategy;
|
||||
import org.hibernate.engine.FetchStyle;
|
||||
import org.hibernate.engine.FetchTiming;
|
||||
import org.hibernate.engine.profile.Fetch;
|
||||
|
@ -19,13 +18,14 @@ import org.hibernate.persister.collection.AbstractCollectionPersister;
|
|||
import org.hibernate.persister.collection.CollectionPersister;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.persister.entity.OuterJoinLoadable;
|
||||
import org.hibernate.sql.results.graph.FetchOptions;
|
||||
import org.hibernate.type.AssociationType;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public final class FetchStrategyHelper {
|
||||
private FetchStrategyHelper() {
|
||||
public final class FetchOptionsHelper {
|
||||
private FetchOptionsHelper() {
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -150,8 +150,8 @@ public final class FetchStrategyHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean isJoinFetched(FetchStrategy fetchStrategy) {
|
||||
return fetchStrategy.getTiming() == FetchTiming.IMMEDIATE
|
||||
&& fetchStrategy.getStyle() == FetchStyle.JOIN;
|
||||
public static boolean isJoinFetched(FetchOptions fetchOptions) {
|
||||
return fetchOptions.getTiming() == FetchTiming.IMMEDIATE
|
||||
&& fetchOptions.getStyle() == FetchStyle.JOIN;
|
||||
}
|
||||
}
|
|
@ -6,11 +6,11 @@
|
|||
*/
|
||||
package org.hibernate.persister.walking.spi;
|
||||
|
||||
import org.hibernate.engine.FetchStrategy;
|
||||
import org.hibernate.engine.spi.CascadeStyle;
|
||||
import org.hibernate.engine.spi.LoadQueryInfluencers;
|
||||
import org.hibernate.loader.PropertyPath;
|
||||
import org.hibernate.persister.spi.HydratedCompoundValueHandler;
|
||||
import org.hibernate.sql.results.graph.FetchOptions;
|
||||
import org.hibernate.type.AssociationType;
|
||||
|
||||
/**
|
||||
|
@ -36,7 +36,7 @@ public interface AssociationAttributeDefinition extends AttributeDefinition {
|
|||
|
||||
AnyMappingDefinition toAnyDefinition();
|
||||
|
||||
FetchStrategy determineFetchPlan(LoadQueryInfluencers loadQueryInfluencers, PropertyPath propertyPath);
|
||||
FetchOptions determineFetchPlan(LoadQueryInfluencers loadQueryInfluencers, PropertyPath propertyPath);
|
||||
|
||||
CascadeStyle determineCascadeStyle();
|
||||
|
||||
|
|
|
@ -4556,7 +4556,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
|||
if ( !( fetchable instanceof CollectionPart ) ) {
|
||||
if ( entityGraphTraversalState != null ) {
|
||||
traversalResult = entityGraphTraversalState.traverse( fetchParent, fetchable, isKeyFetchable );
|
||||
fetchTiming = traversalResult.getFetchStrategy();
|
||||
fetchTiming = traversalResult.getFetchTiming();
|
||||
joined = traversalResult.isJoined();
|
||||
}
|
||||
else if ( getLoadQueryInfluencers().hasEnabledFetchProfiles() ) {
|
||||
|
|
|
@ -67,7 +67,7 @@ public interface DomainResultCreationState {
|
|||
* so something like:
|
||||
* List<Fetch> visitFetches(
|
||||
* FetchParent fetchParent,
|
||||
* BiFunction<FetchParent,Fetchable,(FetchTiming,`selected`)> fetchStrategyResolver,
|
||||
* BiFunction<FetchParent,Fetchable,(FetchTiming,`selected`)> fetchOptionsResolver,
|
||||
* BiFunction<FetchParent,Fetchable,LockMode> lockModeResolver)
|
||||
*
|
||||
* [1] `selected` refers to the named parameter in
|
||||
|
|
|
@ -38,7 +38,7 @@ public interface EntityGraphTraversalState {
|
|||
return previousContext;
|
||||
}
|
||||
|
||||
public FetchTiming getFetchStrategy() {
|
||||
public FetchTiming getFetchTiming() {
|
||||
return fetchTiming;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,4 +15,8 @@ import org.hibernate.engine.FetchTiming;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface FetchOptions extends FetchTimingAccess, FetchStyleAccess {
|
||||
|
||||
static FetchOptions valueOf(FetchTiming fetchTiming, FetchStyle fetchStyle) {
|
||||
return new FetchOptionsImpl( fetchTiming, fetchStyle );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.sql.results.graph;
|
||||
|
||||
import org.hibernate.engine.FetchStyle;
|
||||
import org.hibernate.engine.FetchTiming;
|
||||
|
||||
class FetchOptionsImpl implements FetchOptions {
|
||||
private final FetchTiming fetchTiming;
|
||||
private final FetchStyle fetchStyle;
|
||||
|
||||
FetchOptionsImpl(FetchTiming fetchTiming, FetchStyle fetchStyle) {
|
||||
this.fetchTiming = fetchTiming;
|
||||
this.fetchStyle = fetchStyle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchStyle getStyle() {
|
||||
return fetchStyle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchTiming getTiming() {
|
||||
return fetchTiming;
|
||||
}
|
||||
}
|
|
@ -19,11 +19,6 @@ public interface Fetchable extends ModelPart {
|
|||
|
||||
FetchOptions getMappedFetchOptions();
|
||||
|
||||
// todo (6.0) : all we need here is (1) FetchTiming and (2) whether the values are available in the current JdbcValuesSource
|
||||
// Having to instantiate new FetchStrategy potentially multiple times
|
||||
// per Fetch generation is performance drain. Would be better to
|
||||
// simply pass these 2 pieces of information
|
||||
|
||||
default Fetch resolveCircularFetch(
|
||||
NavigablePath fetchablePath,
|
||||
FetchParent fetchParent,
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
package org.hibernate.sql.results.internal.domain;
|
||||
|
||||
import org.hibernate.LockMode;
|
||||
import org.hibernate.engine.FetchStrategy;
|
||||
import org.hibernate.engine.FetchTiming;
|
||||
import org.hibernate.engine.spi.CollectionKey;
|
||||
import org.hibernate.engine.spi.EntityKey;
|
||||
|
@ -27,6 +26,7 @@ import org.hibernate.sql.results.graph.BiDirectionalFetch;
|
|||
import org.hibernate.sql.results.graph.DomainResultAssembler;
|
||||
import org.hibernate.sql.results.graph.DomainResultCreationState;
|
||||
import org.hibernate.sql.results.graph.Fetch;
|
||||
import org.hibernate.sql.results.graph.FetchOptions;
|
||||
import org.hibernate.sql.results.graph.FetchParent;
|
||||
import org.hibernate.sql.results.graph.FetchParentAccess;
|
||||
import org.hibernate.sql.results.graph.Fetchable;
|
||||
|
@ -141,7 +141,7 @@ public class CircularBiDirectionalFetchImpl implements BiDirectionalFetch, Assoc
|
|||
}
|
||||
|
||||
@Override
|
||||
public FetchStrategy getMappedFetchOptions() {
|
||||
public FetchOptions getMappedFetchOptions() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
package org.hibernate.tuple.component;
|
||||
|
||||
import org.hibernate.FetchMode;
|
||||
import org.hibernate.engine.FetchStrategy;
|
||||
import org.hibernate.engine.FetchStyle;
|
||||
import org.hibernate.engine.FetchTiming;
|
||||
import org.hibernate.engine.spi.CascadeStyle;
|
||||
|
@ -18,7 +17,7 @@ import org.hibernate.persister.collection.CollectionPersister;
|
|||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.persister.entity.Joinable;
|
||||
import org.hibernate.persister.spi.HydratedCompoundValueHandler;
|
||||
import org.hibernate.persister.walking.internal.FetchStrategyHelper;
|
||||
import org.hibernate.persister.walking.internal.FetchOptionsHelper;
|
||||
import org.hibernate.persister.walking.internal.StandardAnyTypeDefinition;
|
||||
import org.hibernate.persister.walking.spi.AnyMappingDefinition;
|
||||
import org.hibernate.persister.walking.spi.AssociationAttributeDefinition;
|
||||
|
@ -26,6 +25,7 @@ import org.hibernate.persister.walking.spi.AssociationKey;
|
|||
import org.hibernate.persister.walking.spi.CollectionDefinition;
|
||||
import org.hibernate.persister.walking.spi.EntityDefinition;
|
||||
import org.hibernate.persister.walking.spi.WalkingException;
|
||||
import org.hibernate.sql.results.graph.FetchOptions;
|
||||
import org.hibernate.tuple.AbstractNonIdentifierAttribute;
|
||||
import org.hibernate.tuple.BaselineAttributeInformation;
|
||||
import org.hibernate.tuple.NonIdentifierAttribute;
|
||||
|
@ -138,10 +138,10 @@ public class CompositeBasedAssociationAttribute
|
|||
}
|
||||
|
||||
@Override
|
||||
public FetchStrategy determineFetchPlan(LoadQueryInfluencers loadQueryInfluencers, PropertyPath propertyPath) {
|
||||
public FetchOptions determineFetchPlan(LoadQueryInfluencers loadQueryInfluencers, PropertyPath propertyPath) {
|
||||
final EntityPersister owningPersister = getSource().locateOwningPersister();
|
||||
|
||||
FetchStyle style = FetchStrategyHelper.determineFetchStyleByProfile(
|
||||
FetchStyle style = FetchOptionsHelper.determineFetchStyleByProfile(
|
||||
loadQueryInfluencers,
|
||||
owningPersister,
|
||||
propertyPath,
|
||||
|
@ -151,15 +151,15 @@ public class CompositeBasedAssociationAttribute
|
|||
style = determineFetchStyleByMetadata( getFetchMode(), getType() );
|
||||
}
|
||||
|
||||
return new FetchStrategy( determineFetchTiming( style ), style );
|
||||
return FetchOptions.valueOf( determineFetchTiming( style ), style );
|
||||
}
|
||||
|
||||
protected FetchStyle determineFetchStyleByMetadata(FetchMode fetchMode, AssociationType type) {
|
||||
return FetchStrategyHelper.determineFetchStyleByMetadata( fetchMode, type, sessionFactory() );
|
||||
return FetchOptionsHelper.determineFetchStyleByMetadata( fetchMode, type, sessionFactory() );
|
||||
}
|
||||
|
||||
private FetchTiming determineFetchTiming(FetchStyle style) {
|
||||
return FetchStrategyHelper.determineFetchTiming( style, getType(), sessionFactory() );
|
||||
return FetchOptionsHelper.determineFetchTiming( style, getType(), sessionFactory() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
*/
|
||||
package org.hibernate.tuple.entity;
|
||||
|
||||
import org.hibernate.engine.FetchStrategy;
|
||||
import org.hibernate.engine.FetchStyle;
|
||||
import org.hibernate.engine.FetchTiming;
|
||||
import org.hibernate.engine.internal.JoinHelper;
|
||||
import org.hibernate.engine.spi.CascadeStyle;
|
||||
import org.hibernate.engine.spi.LoadQueryInfluencers;
|
||||
|
@ -18,7 +18,7 @@ import org.hibernate.persister.entity.EntityPersister;
|
|||
import org.hibernate.persister.entity.Joinable;
|
||||
import org.hibernate.persister.entity.OuterJoinLoadable;
|
||||
import org.hibernate.persister.spi.HydratedCompoundValueHandler;
|
||||
import org.hibernate.persister.walking.internal.FetchStrategyHelper;
|
||||
import org.hibernate.persister.walking.internal.FetchOptionsHelper;
|
||||
import org.hibernate.persister.walking.internal.StandardAnyTypeDefinition;
|
||||
import org.hibernate.persister.walking.spi.AnyMappingDefinition;
|
||||
import org.hibernate.persister.walking.spi.AssociationAttributeDefinition;
|
||||
|
@ -26,6 +26,7 @@ import org.hibernate.persister.walking.spi.AssociationKey;
|
|||
import org.hibernate.persister.walking.spi.CollectionDefinition;
|
||||
import org.hibernate.persister.walking.spi.EntityDefinition;
|
||||
import org.hibernate.persister.walking.spi.WalkingException;
|
||||
import org.hibernate.sql.results.graph.FetchOptions;
|
||||
import org.hibernate.tuple.BaselineAttributeInformation;
|
||||
import org.hibernate.type.AnyType;
|
||||
import org.hibernate.type.AssociationType;
|
||||
|
@ -156,27 +157,26 @@ public class EntityBasedAssociationAttribute
|
|||
}
|
||||
|
||||
@Override
|
||||
public FetchStrategy determineFetchPlan(LoadQueryInfluencers loadQueryInfluencers, PropertyPath propertyPath) {
|
||||
public FetchOptions determineFetchPlan(LoadQueryInfluencers loadQueryInfluencers, PropertyPath propertyPath) {
|
||||
final EntityPersister owningPersister = getSource().getEntityPersister();
|
||||
|
||||
FetchStyle style = FetchStrategyHelper.determineFetchStyleByProfile(
|
||||
FetchStyle style = FetchOptionsHelper.determineFetchStyleByProfile(
|
||||
loadQueryInfluencers,
|
||||
owningPersister,
|
||||
propertyPath,
|
||||
attributeNumber()
|
||||
);
|
||||
if ( style == null ) {
|
||||
style = FetchStrategyHelper.determineFetchStyleByMetadata(
|
||||
style = FetchOptionsHelper.determineFetchStyleByMetadata(
|
||||
( (OuterJoinLoadable) getSource().getEntityPersister() ).getFetchMode( attributeNumber() ),
|
||||
getType(),
|
||||
sessionFactory()
|
||||
);
|
||||
}
|
||||
|
||||
return new FetchStrategy(
|
||||
FetchStrategyHelper.determineFetchTiming( style, getType(), sessionFactory() ),
|
||||
style
|
||||
);
|
||||
final FetchTiming timing = FetchOptionsHelper.determineFetchTiming( style, getType(), sessionFactory() );
|
||||
|
||||
return FetchOptions.valueOf( timing, style );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.test.fetchstrategyhelper;
|
||||
package org.hibernate.test.fetchoptionshelper;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
@ -23,7 +23,7 @@ import org.hibernate.engine.FetchStyle;
|
|||
import org.hibernate.engine.FetchTiming;
|
||||
import org.hibernate.persister.entity.OuterJoinLoadable;
|
||||
import org.hibernate.persister.entity.UniqueKeyLoadable;
|
||||
import org.hibernate.persister.walking.internal.FetchStrategyHelper;
|
||||
import org.hibernate.persister.walking.internal.FetchOptionsHelper;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.hibernate.type.AssociationType;
|
||||
|
||||
|
@ -32,21 +32,21 @@ import static org.junit.Assert.assertSame;
|
|||
/**
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class BatchFetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
|
||||
public class BatchFetchOptionsHelperTest extends BaseCoreFunctionalTestCase {
|
||||
|
||||
@Test
|
||||
public void testManyToOneDefaultFetch() {
|
||||
final AssociationType associationType = determineAssociationType( AnEntity.class, "otherEntityDefault" );
|
||||
final org.hibernate.FetchMode fetchMode = determineFetchMode( AnEntity.class, "otherEntityDefault" );
|
||||
assertSame( org.hibernate.FetchMode.JOIN, fetchMode );
|
||||
final FetchStyle fetchStyle = FetchStrategyHelper.determineFetchStyleByMetadata(
|
||||
final FetchStyle fetchStyle = FetchOptionsHelper.determineFetchStyleByMetadata(
|
||||
fetchMode,
|
||||
associationType,
|
||||
sessionFactory()
|
||||
);
|
||||
// batch size is ignored with org.hibernate.FetchMode.JOIN
|
||||
assertSame( FetchStyle.JOIN, fetchStyle );
|
||||
final FetchTiming fetchTiming = FetchStrategyHelper.determineFetchTiming(
|
||||
final FetchTiming fetchTiming = FetchOptionsHelper.determineFetchTiming(
|
||||
fetchStyle,
|
||||
associationType,
|
||||
sessionFactory()
|
||||
|
@ -59,14 +59,14 @@ public class BatchFetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
|
|||
final AssociationType associationType = determineAssociationType( AnEntity.class, "otherEntityJoin" );
|
||||
final org.hibernate.FetchMode fetchMode = determineFetchMode( AnEntity.class, "otherEntityJoin" );
|
||||
assertSame( org.hibernate.FetchMode.JOIN, fetchMode );
|
||||
final FetchStyle fetchStyle = FetchStrategyHelper.determineFetchStyleByMetadata(
|
||||
final FetchStyle fetchStyle = FetchOptionsHelper.determineFetchStyleByMetadata(
|
||||
fetchMode,
|
||||
associationType,
|
||||
sessionFactory()
|
||||
);
|
||||
// batch size is ignored with org.hibernate.FetchMode.JOIN
|
||||
assertSame( FetchStyle.JOIN, fetchStyle );
|
||||
final FetchTiming fetchTiming = FetchStrategyHelper.determineFetchTiming(
|
||||
final FetchTiming fetchTiming = FetchOptionsHelper.determineFetchTiming(
|
||||
fetchStyle,
|
||||
associationType,
|
||||
sessionFactory()
|
||||
|
@ -79,13 +79,13 @@ public class BatchFetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
|
|||
final AssociationType associationType = determineAssociationType( AnEntity.class, "otherEntitySelect" );
|
||||
final org.hibernate.FetchMode fetchMode = determineFetchMode( AnEntity.class, "otherEntitySelect" );
|
||||
assertSame( org.hibernate.FetchMode.SELECT, fetchMode );
|
||||
final FetchStyle fetchStyle = FetchStrategyHelper.determineFetchStyleByMetadata(
|
||||
final FetchStyle fetchStyle = FetchOptionsHelper.determineFetchStyleByMetadata(
|
||||
fetchMode,
|
||||
associationType,
|
||||
sessionFactory()
|
||||
);
|
||||
assertSame( FetchStyle.BATCH, fetchStyle );
|
||||
final FetchTiming fetchTiming = FetchStrategyHelper.determineFetchTiming(
|
||||
final FetchTiming fetchTiming = FetchOptionsHelper.determineFetchTiming(
|
||||
fetchStyle,
|
||||
associationType,
|
||||
sessionFactory()
|
||||
|
@ -98,13 +98,13 @@ public class BatchFetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
|
|||
final AssociationType associationType = determineAssociationType( AnEntity.class, "colorsDefault" );
|
||||
final org.hibernate.FetchMode fetchMode = determineFetchMode( AnEntity.class, "colorsDefault" );
|
||||
assertSame( org.hibernate.FetchMode.SELECT, fetchMode );
|
||||
final FetchStyle fetchStyle = FetchStrategyHelper.determineFetchStyleByMetadata(
|
||||
final FetchStyle fetchStyle = FetchOptionsHelper.determineFetchStyleByMetadata(
|
||||
fetchMode,
|
||||
associationType,
|
||||
sessionFactory()
|
||||
);
|
||||
assertSame( FetchStyle.BATCH, fetchStyle );
|
||||
final FetchTiming fetchTiming = FetchStrategyHelper.determineFetchTiming(
|
||||
final FetchTiming fetchTiming = FetchOptionsHelper.determineFetchTiming(
|
||||
fetchStyle,
|
||||
associationType,
|
||||
sessionFactory()
|
||||
|
@ -117,14 +117,14 @@ public class BatchFetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
|
|||
final AssociationType associationType = determineAssociationType( AnEntity.class, "colorsJoin" );
|
||||
final org.hibernate.FetchMode fetchMode = determineFetchMode( AnEntity.class, "colorsJoin" );
|
||||
assertSame( org.hibernate.FetchMode.JOIN, fetchMode );
|
||||
final FetchStyle fetchStyle = FetchStrategyHelper.determineFetchStyleByMetadata(
|
||||
final FetchStyle fetchStyle = FetchOptionsHelper.determineFetchStyleByMetadata(
|
||||
fetchMode,
|
||||
associationType,
|
||||
sessionFactory()
|
||||
);
|
||||
// batch size is ignored with org.hibernate.FetchMode.JOIN
|
||||
assertSame( FetchStyle.JOIN, fetchStyle );
|
||||
final FetchTiming fetchTiming = FetchStrategyHelper.determineFetchTiming(
|
||||
final FetchTiming fetchTiming = FetchOptionsHelper.determineFetchTiming(
|
||||
fetchStyle,
|
||||
associationType,
|
||||
sessionFactory()
|
||||
|
@ -137,13 +137,13 @@ public class BatchFetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
|
|||
final AssociationType associationType = determineAssociationType( AnEntity.class, "colorsSelect" );
|
||||
final org.hibernate.FetchMode fetchMode = determineFetchMode( AnEntity.class, "colorsSelect" );
|
||||
assertSame( org.hibernate.FetchMode.SELECT, fetchMode );
|
||||
final FetchStyle fetchStyle = FetchStrategyHelper.determineFetchStyleByMetadata(
|
||||
final FetchStyle fetchStyle = FetchOptionsHelper.determineFetchStyleByMetadata(
|
||||
fetchMode,
|
||||
associationType,
|
||||
sessionFactory()
|
||||
);
|
||||
assertSame( FetchStyle.BATCH, fetchStyle );
|
||||
final FetchTiming fetchTiming = FetchStrategyHelper.determineFetchTiming(
|
||||
final FetchTiming fetchTiming = FetchOptionsHelper.determineFetchTiming(
|
||||
fetchStyle,
|
||||
associationType,
|
||||
sessionFactory()
|
||||
|
@ -156,14 +156,14 @@ public class BatchFetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
|
|||
final AssociationType associationType = determineAssociationType( AnEntity.class, "colorsSubselect" );
|
||||
final org.hibernate.FetchMode fetchMode = determineFetchMode( AnEntity.class, "colorsSubselect" );
|
||||
assertSame( org.hibernate.FetchMode.SELECT, fetchMode );
|
||||
final FetchStyle fetchStyle = FetchStrategyHelper.determineFetchStyleByMetadata(
|
||||
final FetchStyle fetchStyle = FetchOptionsHelper.determineFetchStyleByMetadata(
|
||||
fetchMode,
|
||||
associationType,
|
||||
sessionFactory()
|
||||
);
|
||||
// Batch size is ignored with FetchMode.SUBSELECT
|
||||
assertSame( FetchStyle.SUBSELECT, fetchStyle );
|
||||
final FetchTiming fetchTiming = FetchStrategyHelper.determineFetchTiming(
|
||||
final FetchTiming fetchTiming = FetchOptionsHelper.determineFetchTiming(
|
||||
fetchStyle,
|
||||
associationType,
|
||||
sessionFactory()
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.test.fetchstrategyhelper;
|
||||
package org.hibernate.test.fetchoptionshelper;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
@ -22,7 +22,7 @@ import org.hibernate.engine.FetchStyle;
|
|||
import org.hibernate.engine.FetchTiming;
|
||||
import org.hibernate.persister.entity.OuterJoinLoadable;
|
||||
import org.hibernate.persister.entity.UniqueKeyLoadable;
|
||||
import org.hibernate.persister.walking.internal.FetchStrategyHelper;
|
||||
import org.hibernate.persister.walking.internal.FetchOptionsHelper;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.hibernate.type.AssociationType;
|
||||
|
||||
|
@ -31,7 +31,7 @@ import static org.junit.Assert.assertSame;
|
|||
/**
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class FetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
|
||||
public class FetchOptionsHelperTest extends BaseCoreFunctionalTestCase {
|
||||
|
||||
|
||||
@Test
|
||||
|
@ -39,13 +39,13 @@ public class FetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
|
|||
final AssociationType associationType = determineAssociationType( AnEntity.class, "otherEntityDefault" );
|
||||
final org.hibernate.FetchMode fetchMode = determineFetchMode( AnEntity.class, "otherEntityDefault" );
|
||||
assertSame( org.hibernate.FetchMode.JOIN, fetchMode );
|
||||
final FetchStyle fetchStyle = FetchStrategyHelper.determineFetchStyleByMetadata(
|
||||
final FetchStyle fetchStyle = FetchOptionsHelper.determineFetchStyleByMetadata(
|
||||
fetchMode,
|
||||
associationType,
|
||||
sessionFactory()
|
||||
);
|
||||
assertSame( FetchStyle.JOIN, fetchStyle );
|
||||
final FetchTiming fetchTiming = FetchStrategyHelper.determineFetchTiming(
|
||||
final FetchTiming fetchTiming = FetchOptionsHelper.determineFetchTiming(
|
||||
fetchStyle,
|
||||
associationType,
|
||||
sessionFactory()
|
||||
|
@ -58,13 +58,13 @@ public class FetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
|
|||
final AssociationType associationType = determineAssociationType( AnEntity.class, "otherEntityJoin" );
|
||||
final org.hibernate.FetchMode fetchMode = determineFetchMode( AnEntity.class, "otherEntityJoin" );
|
||||
assertSame( org.hibernate.FetchMode.JOIN, fetchMode );
|
||||
final FetchStyle fetchStyle = FetchStrategyHelper.determineFetchStyleByMetadata(
|
||||
final FetchStyle fetchStyle = FetchOptionsHelper.determineFetchStyleByMetadata(
|
||||
fetchMode,
|
||||
associationType,
|
||||
sessionFactory()
|
||||
);
|
||||
assertSame( FetchStyle.JOIN, fetchStyle );
|
||||
final FetchTiming fetchTiming = FetchStrategyHelper.determineFetchTiming(
|
||||
final FetchTiming fetchTiming = FetchOptionsHelper.determineFetchTiming(
|
||||
fetchStyle,
|
||||
associationType,
|
||||
sessionFactory()
|
||||
|
@ -77,13 +77,13 @@ public class FetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
|
|||
final AssociationType associationType = determineAssociationType( AnEntity.class, "otherEntitySelect" );
|
||||
final org.hibernate.FetchMode fetchMode = determineFetchMode( AnEntity.class, "otherEntitySelect" );
|
||||
assertSame( org.hibernate.FetchMode.SELECT, fetchMode );
|
||||
final FetchStyle fetchStyle = FetchStrategyHelper.determineFetchStyleByMetadata(
|
||||
final FetchStyle fetchStyle = FetchOptionsHelper.determineFetchStyleByMetadata(
|
||||
fetchMode,
|
||||
associationType,
|
||||
sessionFactory()
|
||||
);
|
||||
assertSame( FetchStyle.SELECT, fetchStyle );
|
||||
final FetchTiming fetchTiming = FetchStrategyHelper.determineFetchTiming(
|
||||
final FetchTiming fetchTiming = FetchOptionsHelper.determineFetchTiming(
|
||||
fetchStyle,
|
||||
associationType,
|
||||
sessionFactory()
|
||||
|
@ -96,13 +96,13 @@ public class FetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
|
|||
final AssociationType associationType = determineAssociationType( AnEntity.class, "colorsDefault" );
|
||||
final org.hibernate.FetchMode fetchMode = determineFetchMode( AnEntity.class, "colorsDefault" );
|
||||
assertSame( org.hibernate.FetchMode.SELECT, fetchMode );
|
||||
final FetchStyle fetchStyle = FetchStrategyHelper.determineFetchStyleByMetadata(
|
||||
final FetchStyle fetchStyle = FetchOptionsHelper.determineFetchStyleByMetadata(
|
||||
fetchMode,
|
||||
associationType,
|
||||
sessionFactory()
|
||||
);
|
||||
assertSame( FetchStyle.SELECT, fetchStyle );
|
||||
final FetchTiming fetchTiming = FetchStrategyHelper.determineFetchTiming(
|
||||
final FetchTiming fetchTiming = FetchOptionsHelper.determineFetchTiming(
|
||||
fetchStyle,
|
||||
associationType,
|
||||
sessionFactory()
|
||||
|
@ -115,13 +115,13 @@ public class FetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
|
|||
final AssociationType associationType = determineAssociationType( AnEntity.class, "colorsJoin" );
|
||||
final org.hibernate.FetchMode fetchMode = determineFetchMode( AnEntity.class, "colorsJoin" );
|
||||
assertSame( org.hibernate.FetchMode.JOIN, fetchMode );
|
||||
final FetchStyle fetchStyle = FetchStrategyHelper.determineFetchStyleByMetadata(
|
||||
final FetchStyle fetchStyle = FetchOptionsHelper.determineFetchStyleByMetadata(
|
||||
fetchMode,
|
||||
associationType,
|
||||
sessionFactory()
|
||||
);
|
||||
assertSame( FetchStyle.JOIN, fetchStyle );
|
||||
final FetchTiming fetchTiming = FetchStrategyHelper.determineFetchTiming(
|
||||
final FetchTiming fetchTiming = FetchOptionsHelper.determineFetchTiming(
|
||||
fetchStyle,
|
||||
associationType,
|
||||
sessionFactory()
|
||||
|
@ -134,13 +134,13 @@ public class FetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
|
|||
final AssociationType associationType = determineAssociationType( AnEntity.class, "colorsSelect" );
|
||||
final org.hibernate.FetchMode fetchMode = determineFetchMode( AnEntity.class, "colorsSelect" );
|
||||
assertSame( org.hibernate.FetchMode.SELECT, fetchMode );
|
||||
final FetchStyle fetchStyle = FetchStrategyHelper.determineFetchStyleByMetadata(
|
||||
final FetchStyle fetchStyle = FetchOptionsHelper.determineFetchStyleByMetadata(
|
||||
fetchMode,
|
||||
associationType,
|
||||
sessionFactory()
|
||||
);
|
||||
assertSame( FetchStyle.SELECT, fetchStyle );
|
||||
final FetchTiming fetchTiming = FetchStrategyHelper.determineFetchTiming(
|
||||
final FetchTiming fetchTiming = FetchOptionsHelper.determineFetchTiming(
|
||||
fetchStyle,
|
||||
associationType,
|
||||
sessionFactory()
|
||||
|
@ -153,13 +153,13 @@ public class FetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
|
|||
final AssociationType associationType = determineAssociationType( AnEntity.class, "colorsSubselect" );
|
||||
final org.hibernate.FetchMode fetchMode = determineFetchMode( AnEntity.class, "colorsSubselect" );
|
||||
assertSame( org.hibernate.FetchMode.SELECT, fetchMode );
|
||||
final FetchStyle fetchStyle = FetchStrategyHelper.determineFetchStyleByMetadata(
|
||||
final FetchStyle fetchStyle = FetchOptionsHelper.determineFetchStyleByMetadata(
|
||||
fetchMode,
|
||||
associationType,
|
||||
sessionFactory()
|
||||
);
|
||||
assertSame( FetchStyle.SUBSELECT, fetchStyle );
|
||||
final FetchTiming fetchTiming = FetchStrategyHelper.determineFetchTiming(
|
||||
final FetchTiming fetchTiming = FetchOptionsHelper.determineFetchTiming(
|
||||
fetchStyle,
|
||||
associationType,
|
||||
sessionFactory()
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.test.fetchstrategyhelper;
|
||||
package org.hibernate.test.fetchoptionshelper;
|
||||
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
|
@ -20,7 +20,7 @@ import org.hibernate.engine.FetchStyle;
|
|||
import org.hibernate.engine.FetchTiming;
|
||||
import org.hibernate.persister.entity.OuterJoinLoadable;
|
||||
import org.hibernate.persister.entity.UniqueKeyLoadable;
|
||||
import org.hibernate.persister.walking.internal.FetchStrategyHelper;
|
||||
import org.hibernate.persister.walking.internal.FetchOptionsHelper;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.hibernate.type.AssociationType;
|
||||
|
||||
|
@ -29,20 +29,20 @@ import static org.junit.Assert.assertSame;
|
|||
/**
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class NoProxyFetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
|
||||
public class NoProxyFetchOptionsHelperTest extends BaseCoreFunctionalTestCase {
|
||||
|
||||
@Test
|
||||
public void testManyToOneDefaultFetch() {
|
||||
final AssociationType associationType = determineAssociationType( AnEntity.class, "otherEntityDefault" );
|
||||
final org.hibernate.FetchMode fetchMode = determineFetchMode( AnEntity.class, "otherEntityDefault" );
|
||||
assertSame( org.hibernate.FetchMode.JOIN, fetchMode );
|
||||
final FetchStyle fetchStyle = FetchStrategyHelper.determineFetchStyleByMetadata(
|
||||
final FetchStyle fetchStyle = FetchOptionsHelper.determineFetchStyleByMetadata(
|
||||
fetchMode,
|
||||
associationType,
|
||||
sessionFactory()
|
||||
);
|
||||
assertSame( FetchStyle.JOIN, fetchStyle );
|
||||
final FetchTiming fetchTiming = FetchStrategyHelper.determineFetchTiming(
|
||||
final FetchTiming fetchTiming = FetchOptionsHelper.determineFetchTiming(
|
||||
fetchStyle,
|
||||
associationType,
|
||||
sessionFactory()
|
||||
|
@ -55,13 +55,13 @@ public class NoProxyFetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
|
|||
final AssociationType associationType = determineAssociationType( AnEntity.class, "otherEntityJoin" );
|
||||
final org.hibernate.FetchMode fetchMode = determineFetchMode( AnEntity.class, "otherEntityJoin" );
|
||||
assertSame( org.hibernate.FetchMode.JOIN, fetchMode );
|
||||
final FetchStyle fetchStyle = FetchStrategyHelper.determineFetchStyleByMetadata(
|
||||
final FetchStyle fetchStyle = FetchOptionsHelper.determineFetchStyleByMetadata(
|
||||
fetchMode,
|
||||
associationType,
|
||||
sessionFactory()
|
||||
);
|
||||
assertSame( FetchStyle.JOIN, fetchStyle );
|
||||
final FetchTiming fetchTiming = FetchStrategyHelper.determineFetchTiming(
|
||||
final FetchTiming fetchTiming = FetchOptionsHelper.determineFetchTiming(
|
||||
fetchStyle,
|
||||
associationType,
|
||||
sessionFactory()
|
||||
|
@ -74,13 +74,13 @@ public class NoProxyFetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
|
|||
final AssociationType associationType = determineAssociationType( AnEntity.class, "otherEntitySelect" );
|
||||
final org.hibernate.FetchMode fetchMode = determineFetchMode( AnEntity.class, "otherEntitySelect" );
|
||||
assertSame( org.hibernate.FetchMode.SELECT, fetchMode );
|
||||
final FetchStyle fetchStyle = FetchStrategyHelper.determineFetchStyleByMetadata(
|
||||
final FetchStyle fetchStyle = FetchOptionsHelper.determineFetchStyleByMetadata(
|
||||
fetchMode,
|
||||
associationType,
|
||||
sessionFactory()
|
||||
);
|
||||
assertSame( FetchStyle.SELECT, fetchStyle );
|
||||
final FetchTiming fetchTiming = FetchStrategyHelper.determineFetchTiming(
|
||||
final FetchTiming fetchTiming = FetchOptionsHelper.determineFetchTiming(
|
||||
fetchStyle,
|
||||
associationType,
|
||||
sessionFactory()
|
Loading…
Reference in New Issue