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;
}
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;
}
Aggregations