mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-27 22:39:13 +00:00
Prefer FetchOptions
over FetchStrategy
This commit is contained in:
parent
d3f6f46980
commit
bf575ef065
@ -6,12 +6,14 @@
|
||||
*/
|
||||
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 {
|
||||
public class FetchStrategy implements FetchOptions {
|
||||
public static FetchStrategy IMMEDIATE_JOIN = new FetchStrategy( FetchTiming.IMMEDIATE, FetchStyle.JOIN );
|
||||
|
||||
private final FetchTiming timing;
|
||||
@ -28,10 +30,12 @@ public FetchStrategy(FetchTiming timing, FetchStyle style) {
|
||||
this.style = style;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchTiming getTiming() {
|
||||
return timing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchStyle getStyle() {
|
||||
return style;
|
||||
}
|
||||
|
@ -455,8 +455,8 @@ private BiConsumer<Fetchable, Boolean> createFetchableBiConsumer(
|
||||
}
|
||||
|
||||
final LockMode lockMode = LockMode.READ;
|
||||
FetchTiming fetchTiming = fetchable.getMappedFetchStrategy().getTiming();
|
||||
boolean joined = fetchable.getMappedFetchStrategy().getStyle() == FetchStyle.JOIN;
|
||||
FetchTiming fetchTiming = fetchable.getMappedFetchOptions().getTiming();
|
||||
boolean joined = fetchable.getMappedFetchOptions().getStyle() == FetchStyle.JOIN;
|
||||
|
||||
EntityGraphTraversalState.TraversalResult traversalResult = null;
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
package org.hibernate.metamodel.mapping.internal;
|
||||
|
||||
import org.hibernate.LockMode;
|
||||
import org.hibernate.engine.FetchStrategy;
|
||||
import org.hibernate.engine.FetchStyle;
|
||||
import org.hibernate.engine.FetchTiming;
|
||||
import org.hibernate.metamodel.mapping.EntityDiscriminatorMapping;
|
||||
import org.hibernate.metamodel.mapping.JdbcMapping;
|
||||
@ -20,6 +20,7 @@
|
||||
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.basic.BasicFetch;
|
||||
import org.hibernate.sql.results.graph.basic.BasicResult;
|
||||
@ -29,7 +30,7 @@
|
||||
/**
|
||||
* @author Andrea Boriero
|
||||
*/
|
||||
public abstract class AbstractEntityDiscriminatorMapping implements EntityDiscriminatorMapping {
|
||||
public abstract class AbstractEntityDiscriminatorMapping implements EntityDiscriminatorMapping, FetchOptions {
|
||||
private final EntityPersister entityDescriptor;
|
||||
private final String tableExpression;
|
||||
private final String mappedColumnExpression;
|
||||
@ -67,8 +68,18 @@ public String getFetchableName() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchStrategy getMappedFetchStrategy() {
|
||||
return FetchStrategy.IMMEDIATE_JOIN;
|
||||
public FetchOptions getMappedFetchOptions() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchStyle getStyle() {
|
||||
return FetchStyle.JOIN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchTiming getTiming() {
|
||||
return FetchTiming.IMMEDIATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -7,32 +7,54 @@
|
||||
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.StateArrayContributorMapping;
|
||||
import org.hibernate.metamodel.mapping.StateArrayContributorMetadataAccess;
|
||||
import org.hibernate.sql.results.graph.FetchOptions;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public abstract class AbstractStateArrayContributorMapping
|
||||
extends AbstractAttributeMapping
|
||||
implements StateArrayContributorMapping {
|
||||
implements StateArrayContributorMapping, FetchOptions {
|
||||
|
||||
private final StateArrayContributorMetadataAccess attributeMetadataAccess;
|
||||
private final FetchTiming fetchTiming;
|
||||
private final FetchStyle fetchStyle;
|
||||
private final int stateArrayPosition;
|
||||
private final FetchStrategy mappedFetchStrategy;
|
||||
|
||||
|
||||
public AbstractStateArrayContributorMapping(
|
||||
String name,
|
||||
StateArrayContributorMetadataAccess attributeMetadataAccess,
|
||||
FetchTiming fetchTiming,
|
||||
FetchStyle fetchStyle,
|
||||
int stateArrayPosition,
|
||||
ManagedMappingType declaringType) {
|
||||
super( name, declaringType );
|
||||
this.attributeMetadataAccess = attributeMetadataAccess;
|
||||
this.fetchTiming = fetchTiming;
|
||||
this.fetchStyle = fetchStyle;
|
||||
this.stateArrayPosition = stateArrayPosition;
|
||||
}
|
||||
|
||||
public AbstractStateArrayContributorMapping(
|
||||
String name,
|
||||
StateArrayContributorMetadataAccess attributeMetadataAccess,
|
||||
FetchStrategy mappedFetchStrategy,
|
||||
int stateArrayPosition,
|
||||
ManagedMappingType declaringType) {
|
||||
super( name, declaringType );
|
||||
this.attributeMetadataAccess = attributeMetadataAccess;
|
||||
this.mappedFetchStrategy = mappedFetchStrategy;
|
||||
this.stateArrayPosition = stateArrayPosition;
|
||||
this(
|
||||
name,
|
||||
attributeMetadataAccess,
|
||||
mappedFetchStrategy.getTiming(),
|
||||
mappedFetchStrategy.getStyle(),
|
||||
stateArrayPosition,
|
||||
declaringType
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -51,7 +73,17 @@ public String getFetchableName() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchStrategy getMappedFetchStrategy() {
|
||||
return mappedFetchStrategy;
|
||||
public FetchOptions getMappedFetchOptions() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchStyle getStyle() {
|
||||
return fetchStyle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchTiming getTiming() {
|
||||
return fetchTiming;
|
||||
}
|
||||
}
|
||||
|
@ -10,9 +10,8 @@
|
||||
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.ManagedEntity;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
@ -39,6 +38,7 @@
|
||||
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.basic.BasicFetch;
|
||||
import org.hibernate.sql.results.graph.basic.BasicResult;
|
||||
@ -49,7 +49,7 @@
|
||||
/**
|
||||
* @author Andrea Boriero
|
||||
*/
|
||||
public class BasicEntityIdentifierMappingImpl implements BasicEntityIdentifierMapping {
|
||||
public class BasicEntityIdentifierMappingImpl implements BasicEntityIdentifierMapping, FetchOptions {
|
||||
private final PropertyAccess propertyAccess;
|
||||
private final EntityPersister entityPersister;
|
||||
private final SessionFactoryImplementor sessionFactory;
|
||||
@ -258,8 +258,8 @@ public String getFetchableName() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchStrategy getMappedFetchStrategy() {
|
||||
return FetchStrategy.IMMEDIATE_JOIN;
|
||||
public FetchOptions getMappedFetchOptions() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -282,4 +282,14 @@ public Fetch generateFetch(
|
||||
creationState
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchStyle getStyle() {
|
||||
return FetchStyle.JOIN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchTiming getTiming() {
|
||||
return FetchTiming.IMMEDIATE;
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.LockMode;
|
||||
import org.hibernate.engine.FetchStrategy;
|
||||
import org.hibernate.engine.FetchStyle;
|
||||
import org.hibernate.engine.FetchTiming;
|
||||
import org.hibernate.metamodel.mapping.BasicValuedModelPart;
|
||||
import org.hibernate.metamodel.mapping.CollectionPart;
|
||||
@ -30,10 +30,10 @@
|
||||
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.basic.BasicFetch;
|
||||
import org.hibernate.sql.results.graph.basic.BasicResult;
|
||||
import org.hibernate.type.BasicType;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
@ -42,7 +42,8 @@
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class BasicValuedCollectionPart implements CollectionPart, BasicValuedModelPart, ConvertibleModelPart {
|
||||
public class BasicValuedCollectionPart
|
||||
implements CollectionPart, BasicValuedModelPart, ConvertibleModelPart, FetchOptions {
|
||||
private final NavigableRole navigableRole;
|
||||
private final CollectionPersister collectionDescriptor;
|
||||
private final Nature nature;
|
||||
@ -166,8 +167,8 @@ public String getFetchableName() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchStrategy getMappedFetchStrategy() {
|
||||
return FetchStrategy.IMMEDIATE_JOIN;
|
||||
public FetchOptions getMappedFetchOptions() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -212,6 +213,16 @@ public List<JdbcMapping> getJdbcMappings(TypeConfiguration typeConfiguration) {
|
||||
return Collections.singletonList( getJdbcMapping() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchStyle getStyle() {
|
||||
return FetchStyle.JOIN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchTiming getTiming() {
|
||||
return FetchTiming.IMMEDIATE;
|
||||
}
|
||||
|
||||
//
|
||||
// @Override
|
||||
// public BasicType getBasicType() {
|
||||
|
@ -7,7 +7,7 @@
|
||||
package org.hibernate.metamodel.mapping.internal;
|
||||
|
||||
import org.hibernate.LockMode;
|
||||
import org.hibernate.engine.FetchStrategy;
|
||||
import org.hibernate.engine.FetchStyle;
|
||||
import org.hibernate.engine.FetchTiming;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.metamodel.mapping.CollectionIdentifierDescriptor;
|
||||
@ -27,6 +27,7 @@
|
||||
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.basic.BasicFetch;
|
||||
import org.hibernate.sql.results.graph.basic.BasicResult;
|
||||
@ -36,7 +37,7 @@
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class CollectionIdentifierDescriptorImpl implements CollectionIdentifierDescriptor {
|
||||
public class CollectionIdentifierDescriptorImpl implements CollectionIdentifierDescriptor, FetchOptions {
|
||||
private final NavigableRole navigableRole;
|
||||
private final CollectionPersister collectionDescriptor;
|
||||
private final String containingTableName;
|
||||
@ -106,8 +107,8 @@ public String getFetchableName() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchStrategy getMappedFetchStrategy() {
|
||||
return null;
|
||||
public FetchOptions getMappedFetchOptions() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -196,4 +197,14 @@ public DomainResult createDomainResult(
|
||||
public String toString() {
|
||||
return getClass().getSimpleName() + "(" + collectionDescriptor.getRole() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchStyle getStyle() {
|
||||
return FetchStyle.JOIN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchTiming getTiming() {
|
||||
return FetchTiming.IMMEDIATE;
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
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.metamodel.mapping.CollectionPart;
|
||||
@ -40,6 +41,7 @@
|
||||
import org.hibernate.sql.ast.tree.from.TableGroupJoin;
|
||||
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.embeddable.internal.EmbeddableFetchImpl;
|
||||
@ -49,7 +51,7 @@
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class EmbeddedCollectionPart implements CollectionPart, EmbeddableValuedFetchable {
|
||||
public class EmbeddedCollectionPart implements CollectionPart, EmbeddableValuedFetchable, FetchOptions {
|
||||
private final NavigableRole navigableRole;
|
||||
private final CollectionPersister collectionDescriptor;
|
||||
private final Nature nature;
|
||||
@ -116,10 +118,11 @@ public String getFetchableName() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchStrategy getMappedFetchStrategy() {
|
||||
return FetchStrategy.IMMEDIATE_JOIN;
|
||||
public FetchOptions getMappedFetchOptions() {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getJdbcTypeCount(TypeConfiguration typeConfiguration) {
|
||||
return getEmbeddableTypeDescriptor().getJdbcTypeCount( typeConfiguration );
|
||||
@ -251,4 +254,14 @@ public EntityMappingType findContainingEntityMapping() {
|
||||
public int getNumberOfFetchables() {
|
||||
return getEmbeddableTypeDescriptor().getNumberOfAttributeMappings();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchStyle getStyle() {
|
||||
return FetchStyle.JOIN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchTiming getTiming() {
|
||||
return FetchTiming.IMMEDIATE;
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
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.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
@ -48,6 +48,7 @@
|
||||
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.embeddable.internal.EmbeddableFetchImpl;
|
||||
@ -60,7 +61,8 @@
|
||||
*
|
||||
* @author Andrea Boriero
|
||||
*/
|
||||
public class EmbeddedIdentifierMappingImpl implements CompositeIdentifierMapping, EmbeddableValuedFetchable {
|
||||
public class EmbeddedIdentifierMappingImpl
|
||||
implements CompositeIdentifierMapping, EmbeddableValuedFetchable, FetchOptions {
|
||||
private final NavigableRole navigableRole;
|
||||
private final EntityMappingType entityMapping;
|
||||
private final String name;
|
||||
@ -285,8 +287,8 @@ public String getFetchableName() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchStrategy getMappedFetchStrategy() {
|
||||
return null;
|
||||
public FetchOptions getMappedFetchOptions() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -345,4 +347,13 @@ public Collection<SingularAttributeMapping> getAttributes() {
|
||||
return (Collection) getEmbeddableTypeDescriptor().getAttributeMappings();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchStyle getStyle() {
|
||||
return FetchStyle.JOIN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchTiming getTiming() {
|
||||
return FetchTiming.IMMEDIATE;
|
||||
}
|
||||
}
|
||||
|
@ -6,12 +6,9 @@
|
||||
*/
|
||||
package org.hibernate.metamodel.mapping.internal;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.LockMode;
|
||||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
import org.hibernate.engine.FetchStrategy;
|
||||
import org.hibernate.engine.FetchStyle;
|
||||
import org.hibernate.engine.FetchTiming;
|
||||
import org.hibernate.mapping.Collection;
|
||||
import org.hibernate.mapping.Value;
|
||||
@ -29,6 +26,7 @@
|
||||
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.collection.internal.EntityCollectionPartTableGroup;
|
||||
import org.hibernate.sql.results.graph.entity.EntityFetch;
|
||||
@ -40,7 +38,7 @@
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class EntityCollectionPart
|
||||
implements CollectionPart, EntityAssociationMapping, EntityValuedFetchable, Association {
|
||||
implements CollectionPart, EntityAssociationMapping, EntityValuedFetchable, Association, FetchOptions {
|
||||
private final NavigableRole navigableRole;
|
||||
private final CollectionPersister collectionDescriptor;
|
||||
private final Nature nature;
|
||||
@ -118,8 +116,8 @@ public String getFetchableName() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchStrategy getMappedFetchStrategy() {
|
||||
return FetchStrategy.IMMEDIATE_JOIN;
|
||||
public FetchOptions getMappedFetchOptions() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -203,4 +201,14 @@ public ForeignKeyDescriptor getForeignKeyDescriptor() {
|
||||
// todo (6.0) : this will not strictly work - we'd want a new ForeignKeyDescriptor that points the other direction
|
||||
return collectionDescriptor.getAttributeMapping().getKeyDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchStyle getStyle() {
|
||||
return FetchStyle.JOIN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchTiming getTiming() {
|
||||
return FetchTiming.IMMEDIATE;
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
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.metamodel.mapping.ColumnConsumer;
|
||||
import org.hibernate.metamodel.mapping.EntityMappingType;
|
||||
@ -27,6 +27,7 @@
|
||||
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.basic.BasicFetch;
|
||||
import org.hibernate.sql.results.graph.basic.BasicResult;
|
||||
@ -36,7 +37,7 @@
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class EntityVersionMappingImpl implements EntityVersionMapping {
|
||||
public class EntityVersionMappingImpl implements EntityVersionMapping, FetchOptions {
|
||||
private final String attributeName;
|
||||
private final EntityMappingType declaringType;
|
||||
|
||||
@ -116,8 +117,8 @@ public String getFetchableName() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchStrategy getMappedFetchStrategy() {
|
||||
return FetchStrategy.IMMEDIATE_JOIN;
|
||||
public FetchOptions getMappedFetchOptions() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -214,4 +215,14 @@ public void applySqlSelections(
|
||||
public void visitColumns(ColumnConsumer consumer) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchStyle getStyle() {
|
||||
return FetchStyle.JOIN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchTiming getTiming() {
|
||||
return FetchTiming.IMMEDIATE;
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
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.mapping.Component;
|
||||
@ -39,6 +39,7 @@
|
||||
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.embeddable.internal.EmbeddableFetchImpl;
|
||||
@ -54,7 +55,8 @@
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class NonAggregatedIdentifierMappingImpl implements CompositeIdentifierMapping, EmbeddableValuedFetchable {
|
||||
public class NonAggregatedIdentifierMappingImpl
|
||||
implements CompositeIdentifierMapping, EmbeddableValuedFetchable, FetchOptions {
|
||||
private final EmbeddableMappingType embeddableDescriptor;
|
||||
private final NavigableRole navigableRole;
|
||||
private final EntityMappingType entityMapping;
|
||||
@ -228,8 +230,8 @@ public String getFetchableName() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchStrategy getMappedFetchStrategy() {
|
||||
return null;
|
||||
public FetchOptions getMappedFetchOptions() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -256,4 +258,14 @@ public Fetch generateFetch(
|
||||
public int getNumberOfFetchables() {
|
||||
return idAttributeMappings.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchStyle getStyle() {
|
||||
return FetchStyle.JOIN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchTiming getTiming() {
|
||||
return FetchTiming.IMMEDIATE;
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
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;
|
||||
import org.hibernate.engine.spi.LoadQueryInfluencers;
|
||||
@ -59,6 +60,7 @@
|
||||
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.collection.internal.CollectionDomainResult;
|
||||
import org.hibernate.sql.results.graph.collection.internal.DelayedCollectionFetch;
|
||||
@ -71,7 +73,8 @@
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class PluralAttributeMappingImpl extends AbstractAttributeMapping implements PluralAttributeMapping {
|
||||
public class PluralAttributeMappingImpl extends AbstractAttributeMapping implements PluralAttributeMapping,
|
||||
FetchOptions {
|
||||
private static final Logger log = Logger.getLogger( PluralAttributeMappingImpl.class );
|
||||
|
||||
public interface Aware {
|
||||
@ -87,8 +90,9 @@ public interface Aware {
|
||||
private final CollectionPart elementDescriptor;
|
||||
private final CollectionPart indexDescriptor;
|
||||
private final CollectionIdentifierDescriptor identifierDescriptor;
|
||||
private final FetchTiming fetchTiming;
|
||||
private final FetchStyle fetchStyle;
|
||||
|
||||
private final FetchStrategy fetchStrategy;
|
||||
private final CascadeStyle cascadeStyle;
|
||||
|
||||
private final CollectionPersister collectionDescriptor;
|
||||
@ -119,6 +123,40 @@ public PluralAttributeMappingImpl(
|
||||
CascadeStyle cascadeStyle,
|
||||
ManagedMappingType declaringType,
|
||||
CollectionPersister collectionDescriptor) {
|
||||
this(
|
||||
attributeName,
|
||||
bootDescriptor,
|
||||
propertyAccess,
|
||||
stateArrayContributorMetadataAccess,
|
||||
collectionMappingType,
|
||||
stateArrayPosition,
|
||||
elementDescriptor,
|
||||
indexDescriptor,
|
||||
identifierDescriptor,
|
||||
fetchStrategy.getTiming(),
|
||||
fetchStrategy.getStyle(),
|
||||
cascadeStyle,
|
||||
declaringType,
|
||||
collectionDescriptor
|
||||
);
|
||||
}
|
||||
|
||||
@SuppressWarnings({"WeakerAccess", "rawtypes"})
|
||||
public PluralAttributeMappingImpl(
|
||||
String attributeName,
|
||||
Collection bootDescriptor,
|
||||
PropertyAccess propertyAccess,
|
||||
StateArrayContributorMetadataAccess stateArrayContributorMetadataAccess,
|
||||
CollectionMappingType collectionMappingType,
|
||||
int stateArrayPosition,
|
||||
CollectionPart elementDescriptor,
|
||||
CollectionPart indexDescriptor,
|
||||
CollectionIdentifierDescriptor identifierDescriptor,
|
||||
FetchTiming fetchTiming,
|
||||
FetchStyle fetchStyle,
|
||||
CascadeStyle cascadeStyle,
|
||||
ManagedMappingType declaringType,
|
||||
CollectionPersister collectionDescriptor) {
|
||||
super( attributeName, declaringType );
|
||||
this.propertyAccess = propertyAccess;
|
||||
this.stateArrayContributorMetadataAccess = stateArrayContributorMetadataAccess;
|
||||
@ -127,7 +165,8 @@ public PluralAttributeMappingImpl(
|
||||
this.elementDescriptor = elementDescriptor;
|
||||
this.indexDescriptor = indexDescriptor;
|
||||
this.identifierDescriptor = identifierDescriptor;
|
||||
this.fetchStrategy = fetchStrategy;
|
||||
this.fetchTiming = fetchTiming;
|
||||
this.fetchStyle = fetchStyle;
|
||||
this.cascadeStyle = cascadeStyle;
|
||||
this.collectionDescriptor = collectionDescriptor;
|
||||
|
||||
@ -281,6 +320,11 @@ public JpaCompliance getJpaCompliance() {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NavigableRole getNavigableRole() {
|
||||
return getCollectionDescriptor().getNavigableRole();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
public CollectionMappingType getMappedTypeDescriptor() {
|
||||
@ -353,13 +397,18 @@ public String getFetchableName() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchStrategy getMappedFetchStrategy() {
|
||||
return fetchStrategy;
|
||||
public FetchOptions getMappedFetchOptions() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NavigableRole getNavigableRole() {
|
||||
return getCollectionDescriptor().getNavigableRole();
|
||||
public FetchStyle getStyle() {
|
||||
return fetchStyle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchTiming getTiming() {
|
||||
return fetchTiming;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -11,7 +11,7 @@
|
||||
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.metamodel.mapping.BasicValuedModelPart;
|
||||
@ -38,6 +38,7 @@
|
||||
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.basic.BasicResult;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
@ -46,7 +47,7 @@
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class SimpleForeignKeyDescriptor implements ForeignKeyDescriptor, BasicValuedModelPart {
|
||||
public class SimpleForeignKeyDescriptor implements ForeignKeyDescriptor, BasicValuedModelPart, FetchOptions {
|
||||
private final String keyColumnContainingTable;
|
||||
private final String keyColumnExpression;
|
||||
private final String targetColumnContainingTable;
|
||||
@ -356,8 +357,18 @@ public String getFetchableName() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchStrategy getMappedFetchStrategy() {
|
||||
return FetchStrategy.IMMEDIATE_JOIN;
|
||||
public FetchOptions getMappedFetchOptions() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchStyle getStyle() {
|
||||
return FetchStyle.JOIN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchTiming getTiming() {
|
||||
return FetchTiming.IMMEDIATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -307,7 +307,7 @@ private Fetch buildFetch(NavigablePath fetchablePath, FetchParent fetchParent, F
|
||||
|
||||
final String alias;
|
||||
LockMode lockMode = LockMode.READ;
|
||||
FetchTiming fetchTiming = fetchable.getMappedFetchStrategy().getTiming();
|
||||
FetchTiming fetchTiming = fetchable.getMappedFetchOptions().getTiming();
|
||||
boolean joined = false;
|
||||
|
||||
EntityGraphTraversalState.TraversalResult traversalResult = null;
|
||||
|
@ -6,8 +6,6 @@
|
||||
*/
|
||||
package org.hibernate.sql.results.graph;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.hibernate.engine.FetchTiming;
|
||||
import org.hibernate.query.NavigablePath;
|
||||
|
||||
@ -48,6 +46,8 @@ public interface Fetch extends DomainResultGraphNode {
|
||||
|
||||
/**
|
||||
* immediate or delayed?
|
||||
*
|
||||
* todo (6.0) : should we also expose the fetch-style? Perhaps the fetch-options?
|
||||
*/
|
||||
FetchTiming getTiming();
|
||||
|
||||
|
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Represents an aggregated {@link FetchTiming} and {@link FetchStyle} value
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface FetchOptions extends FetchTimingAccess, FetchStyleAccess {
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Access to a FetchStyle
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface FetchStyleAccess {
|
||||
FetchStyle getStyle();
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* 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.FetchTiming;
|
||||
|
||||
/**
|
||||
* Access to a FetchTiming
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface FetchTimingAccess {
|
||||
FetchTiming getTiming();
|
||||
}
|
@ -7,7 +7,6 @@
|
||||
package org.hibernate.sql.results.graph;
|
||||
|
||||
import org.hibernate.LockMode;
|
||||
import org.hibernate.engine.FetchStrategy;
|
||||
import org.hibernate.engine.FetchTiming;
|
||||
import org.hibernate.metamodel.mapping.ModelPart;
|
||||
import org.hibernate.query.NavigablePath;
|
||||
@ -18,7 +17,7 @@
|
||||
public interface Fetchable extends ModelPart {
|
||||
String getFetchableName();
|
||||
|
||||
FetchStrategy getMappedFetchStrategy();
|
||||
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
|
||||
|
@ -75,7 +75,7 @@ private void generateFetches(
|
||||
associatedEntityMappingType.getIdentifierMapping().getJavaTypeDescriptor()
|
||||
);
|
||||
Fetch fetch;
|
||||
if ( toOneAttributeMapping.getMappedFetchStrategy().getTiming() == FetchTiming.DELAYED ) {
|
||||
if ( toOneAttributeMapping.getMappedFetchOptions().getTiming() == FetchTiming.DELAYED ) {
|
||||
fetch = new EntityFetchDelayedImpl(
|
||||
this,
|
||||
toOneAttributeMapping,
|
||||
|
@ -97,8 +97,8 @@ assert exploreKeySubgraph && isJpaMapCollectionType( pluralAttributeMapping )
|
||||
joined = false;
|
||||
}
|
||||
else {
|
||||
fetchTiming = fetchable.getMappedFetchStrategy().getTiming();
|
||||
joined = fetchable.getMappedFetchStrategy().getStyle() == FetchStyle.JOIN;
|
||||
fetchTiming = fetchable.getMappedFetchOptions().getTiming();
|
||||
joined = fetchable.getMappedFetchOptions().getStyle() == FetchStyle.JOIN;
|
||||
}
|
||||
}
|
||||
return new TraversalResult( previousContextRoot, fetchTiming, joined );
|
||||
|
@ -137,7 +137,7 @@ public JavaTypeDescriptor getJavaTypeDescriptor() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchStrategy getMappedFetchStrategy() {
|
||||
public FetchStrategy getMappedFetchOptions() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user