protected FetchStrategy adjustJoinFetchIfNeeded( AssociationAttributeDefinition attributeDefinition, FetchStrategy fetchStrategy) { if ( lockMode.greaterThan( LockMode.READ ) ) { return new FetchStrategy( fetchStrategy.getTiming(), FetchStyle.SELECT ); } final Integer maxFetchDepth = sessionFactory().getSettings().getMaximumFetchDepth(); if ( maxFetchDepth != null && currentDepth() > maxFetchDepth ) { return new FetchStrategy( fetchStrategy.getTiming(), FetchStyle.SELECT ); } if ( attributeDefinition.getType().isCollectionType() && isTooManyCollections() ) { // todo : have this revert to batch or subselect fetching once "sql gen redesign" is in place return new FetchStrategy( fetchStrategy.getTiming(), FetchStyle.SELECT ); } return fetchStrategy; }
@Override public FetchStrategy determineFetchPlan(LoadQueryInfluencers loadQueryInfluencers, PropertyPath propertyPath) { final EntityPersister owningPersister = getSource().locateOwningPersister(); FetchStyle style = FetchStrategyHelper.determineFetchStyleByProfile( loadQueryInfluencers, owningPersister, propertyPath, attributeNumber() ); if ( style == null ) { style = determineFetchStyleByMetadata( getFetchMode(), getType() ); } return new FetchStrategy( determineFetchTiming( style ), style ); }
@Override public void foundCircularAssociation(AssociationAttributeDefinition attributeDefinition) { final FetchStrategy fetchStrategy = determineFetchStrategy( attributeDefinition ); if ( fetchStrategy.getStyle() != FetchStyle.JOIN ) { return; // nothing to do } // Bi-directional association & the owning side was already visited. If the current attribute node refers // to it, fetch. // ENTITY nature handled by super. final GraphImplementor currentGraph = graphStack.getCurrent(); if ( attributeDefinition.getAssociationNature() == AssociationAttributeDefinition.AssociationNature.COLLECTION && currentGraph != null && currentGraph.findAttributeNode( attributeDefinition.getName() ) != null ) { currentSource().buildCollectionAttributeFetch( attributeDefinition, fetchStrategy ); } super.foundCircularAssociation( attributeDefinition ); } }
@Override public FetchStrategy determineFetchPlan(LoadQueryInfluencers loadQueryInfluencers, PropertyPath propertyPath) { final EntityPersister owningPersister = getSource().getEntityPersister(); FetchStyle style = FetchStrategyHelper.determineFetchStyleByProfile( loadQueryInfluencers, owningPersister, propertyPath, attributeNumber() ); if ( style == null ) { style = FetchStrategyHelper.determineFetchStyleByMetadata( ( (OuterJoinLoadable) getSource().getEntityPersister() ).getFetchMode( attributeNumber() ), getType(), sessionFactory() ); } return new FetchStrategy( FetchStrategyHelper.determineFetchTiming( style, getType(), sessionFactory() ), style ); }
/** * If required by this strategy, returns a different {@link FetchStrategy} from what is specified * for the given association attribute. * * @param attributeDefinition The association attribute definition. * @param fetchStrategy The fetch strategy for <code>attributeDefinition</code>. * @return the {@link FetchStrategy}, possibly adjusted by this strategy. */ protected FetchStrategy adjustJoinFetchIfNeeded( AssociationAttributeDefinition attributeDefinition, FetchStrategy fetchStrategy) { if ( lockMode.greaterThan( LockMode.READ ) ) { return new FetchStrategy( fetchStrategy.getTiming(), FetchStyle.SELECT ); } final Integer maxFetchDepth = sessionFactory().getSessionFactoryOptions().getMaximumFetchDepth(); if ( maxFetchDepth != null && currentDepth() > maxFetchDepth ) { return new FetchStrategy( fetchStrategy.getTiming(), FetchStyle.SELECT ); } if ( attributeDefinition.getType().isCollectionType() && isTooManyCollections() ) { // todo : have this revert to batch or subselect fetching once "sql gen redesign" is in place return new FetchStrategy( fetchStrategy.getTiming(), FetchStyle.SELECT ); } return fetchStrategy; }
public static FetchStrategy determineFetchStrategy(Collection bootCollectionDescriptor) { return new FetchStrategy( determineTiming( bootCollectionDescriptor ), determineStyle( bootCollectionDescriptor ) ); }
@Override protected FetchStrategy determineFetchStrategy(AssociationAttributeDefinition attributeDefinition) { FetchStrategy fetchStrategy = attributeDefinition.determineFetchPlan( loadQueryInfluencers, currentPropertyPath ); if ( fetchStrategy.getTiming() == FetchTiming.IMMEDIATE && fetchStrategy.getStyle() == FetchStyle.JOIN ) { // see if we need to alter the join fetch to another form for any reason fetchStrategy = adjustJoinFetchIfNeeded( attributeDefinition, fetchStrategy ); } return fetchStrategy; }
public static FetchStrategy determineFetchStrategy( PersistentAttributeMapping bootModelAttribute, ManagedTypeDescriptor runtimeModelContainer, EntityTypeDescriptor entityDescriptor) { FetchStyle style = determineStyle( bootModelAttribute, entityDescriptor ); return new FetchStrategy( determineTiming( style, bootModelAttribute, runtimeModelContainer, entityDescriptor ), style ); }
@Override protected FetchStrategy resolveImplicitFetchStrategyFromEntityGraph( final AssociationAttributeDefinition attributeDefinition) { FetchStrategy fetchStrategy = attributeDefinition.determineFetchPlan( loadQueryInfluencers, currentPropertyPath ); if ( fetchStrategy.getTiming() == FetchTiming.IMMEDIATE && fetchStrategy.getStyle() == FetchStyle.JOIN ) { // see if we need to alter the join fetch to another form for any reason fetchStrategy = adjustJoinFetchIfNeeded( attributeDefinition, fetchStrategy ); } return fetchStrategy; }
@SuppressWarnings("unchecked") public SingularPersistentAttributeBasic( ManagedTypeDescriptor<O> runtimeContainer, PersistentAttributeMapping bootAttribute, PropertyAccess propertyAccess, Disposition disposition, RuntimeModelCreationContext context) { super( runtimeContainer, bootAttribute, propertyAccess, disposition ); final BasicValueMapping bootMapping = (BasicValueMapping) bootAttribute.getValueMapping(); this.boundColumn = context.getDatabaseObjectResolver().resolveColumn( bootMapping.getMappedColumn() ); this.valueMapper = bootMapping.getResolution().getValueMapper(); if ( valueMapper.getValueConverter() != null ) { log.debugf( "BasicValueConverter [%s] being applied for basic attribute : %s", valueMapper.getValueConverter(), getNavigableRole() ); } this.fetchStrategy = bootAttribute.isLazy() ? new FetchStrategy( FetchTiming.DELAYED, FetchStyle.SELECT ) : FetchStrategy.IMMEDIATE_JOIN; instantiationComplete( bootAttribute, context ); }
public void processingFetch(Fetch fetch) { if ( ! hasSubselectFetch ) { if ( fetch.getFetchStrategy().getStyle() == FetchStyle.SUBSELECT && fetch.getFetchStrategy().getTiming() != FetchTiming.IMMEDIATE ) { hasSubselectFetch = true; } } if ( isJoinFetchedBag( fetch ) ) { if ( joinedBagAttributeFetches == null ) { joinedBagAttributeFetches = new HashSet<>(); } joinedBagAttributeFetches.add( (CollectionAttributeFetch) fetch ); } }