Search in sources :

Example 1 with FetchProfile

use of org.hibernate.engine.profile.FetchProfile in project hibernate-orm by hibernate.

the class AbstractEntityJoinWalker method isJoinFetchEnabledByProfile.

protected final boolean isJoinFetchEnabledByProfile(OuterJoinLoadable persister, PropertyPath path, int propertyNumber) {
    if (!getLoadQueryInfluencers().hasEnabledFetchProfiles()) {
        // perf optimization
        return false;
    }
    // ugh, this stuff has to be made easier...
    final String fullPath = path.getFullPath();
    String rootPropertyName = persister.getSubclassPropertyName(propertyNumber);
    int pos = fullPath.lastIndexOf(rootPropertyName);
    String relativePropertyPath = pos >= 0 ? fullPath.substring(pos) : rootPropertyName;
    String fetchRole = persister.getEntityName() + "." + relativePropertyPath;
    for (String profileName : getLoadQueryInfluencers().getEnabledFetchProfileNames()) {
        final FetchProfile profile = getFactory().getFetchProfile(profileName);
        final Fetch fetch = profile.getFetchByRole(fetchRole);
        if (fetch != null && Fetch.Style.JOIN == fetch.getStyle()) {
            return true;
        }
    }
    return false;
}
Also used : Fetch(org.hibernate.engine.profile.Fetch) FetchProfile(org.hibernate.engine.profile.FetchProfile)

Example 2 with FetchProfile

use of org.hibernate.engine.profile.FetchProfile in project hibernate-orm by hibernate.

the class FetchStrategyHelper method determineFetchStyleByProfile.

/**
	 * Determine the fetch-style (if one) explicitly set for this association via fetch profiles.
	 * <p/>
	 * Note that currently fetch profiles only allow specifying join fetching, so this method currently
	 * returns either (a) FetchStyle.JOIN or (b) null
	 *
	 * @param loadQueryInfluencers
	 * @param persister
	 * @param path
	 * @param propertyNumber
	 *
	 * @return
	 */
public static FetchStyle determineFetchStyleByProfile(LoadQueryInfluencers loadQueryInfluencers, EntityPersister persister, PropertyPath path, int propertyNumber) {
    if (!loadQueryInfluencers.hasEnabledFetchProfiles()) {
        // perf optimization
        return null;
    }
    // ugh, this stuff has to be made easier...
    final String fullPath = path.getFullPath();
    final String rootPropertyName = ((OuterJoinLoadable) persister).getSubclassPropertyName(propertyNumber);
    int pos = fullPath.lastIndexOf(rootPropertyName);
    final String relativePropertyPath = pos >= 0 ? fullPath.substring(pos) : rootPropertyName;
    final String fetchRole = persister.getEntityName() + "." + relativePropertyPath;
    for (String profileName : loadQueryInfluencers.getEnabledFetchProfileNames()) {
        final FetchProfile profile = loadQueryInfluencers.getSessionFactory().getFetchProfile(profileName);
        final Fetch fetch = profile.getFetchByRole(fetchRole);
        if (fetch != null && Fetch.Style.JOIN == fetch.getStyle()) {
            return FetchStyle.JOIN;
        }
    }
    return null;
}
Also used : Fetch(org.hibernate.engine.profile.Fetch) OuterJoinLoadable(org.hibernate.persister.entity.OuterJoinLoadable) FetchProfile(org.hibernate.engine.profile.FetchProfile)

Aggregations

Fetch (org.hibernate.engine.profile.Fetch)2 FetchProfile (org.hibernate.engine.profile.FetchProfile)2 OuterJoinLoadable (org.hibernate.persister.entity.OuterJoinLoadable)1