use of org.hibernate.persister.entity.OuterJoinLoadable in project hibernate-orm by hibernate.
the class EntityLoadQueryDetails method applyRootReturnSelectFragments.
protected void applyRootReturnSelectFragments(SelectStatementBuilder selectStatementBuilder) {
final OuterJoinLoadable outerJoinLoadable = (OuterJoinLoadable) getRootEntityReturn().getEntityPersister();
selectStatementBuilder.appendSelectClauseFragment(outerJoinLoadable.selectFragment(entityReferenceAliases.getTableAlias(), entityReferenceAliases.getColumnAliases().getSuffix()));
}
use of org.hibernate.persister.entity.OuterJoinLoadable in project hibernate-orm by hibernate.
the class EntityLoadQueryDetails method applyRootReturnWhereJoinRestrictions.
protected void applyRootReturnWhereJoinRestrictions(SelectStatementBuilder selectStatementBuilder) {
final Joinable joinable = (OuterJoinLoadable) getRootEntityReturn().getEntityPersister();
selectStatementBuilder.appendRestrictions(joinable.whereJoinFragment(entityReferenceAliases.getTableAlias(), true, true));
}
use of org.hibernate.persister.entity.OuterJoinLoadable in project hibernate-orm by hibernate.
the class JoinWalker method addAssociationToJoinTree.
/**
* Add on association (one-to-one, many-to-one, or a collection) to a list
* of associations to be fetched by outerjoin
*/
private void addAssociationToJoinTree(final AssociationType type, final String[] aliasedLhsColumns, final String alias, final PropertyPath path, final int currentDepth, final JoinType joinType) throws MappingException {
Joinable joinable = type.getAssociatedJoinable(getFactory());
// important to generate alias based on size of association collection
// *before* adding this join to that collection
String subalias = generateTableAlias(associations.size() + 1, path, joinable);
// NOTE : it should be fine to continue to pass only filters below
// (instead of LoadQueryInfluencers) since "from that point on" we
// only need to worry about restrictions (and not say adding more
// joins)
OuterJoinableAssociation assoc = new OuterJoinableAssociation(path, type, alias, aliasedLhsColumns, subalias, joinType, joinable.consumesEntityAlias() ? getWithClause(path) : "", hasRestriction(path), getFactory(), loadQueryInfluencers.getEnabledFilters());
assoc.validateJoin(path.getFullPath());
associations.add(assoc);
int nextDepth = currentDepth + 1;
// path = "";
if (!joinable.isCollection()) {
if (joinable instanceof OuterJoinLoadable) {
walkEntityTree((OuterJoinLoadable) joinable, subalias, path, nextDepth);
}
} else {
if (joinable instanceof QueryableCollection) {
walkCollectionTree((QueryableCollection) joinable, subalias, path, nextDepth);
}
}
}
use of org.hibernate.persister.entity.OuterJoinLoadable 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;
}
use of org.hibernate.persister.entity.OuterJoinLoadable in project hibernate-orm by hibernate.
the class OneToManyPersister method selectFragment.
public String selectFragment(Joinable rhs, String rhsAlias, String lhsAlias, String entitySuffix, String collectionSuffix, boolean includeCollectionColumns) {
StringBuilder buf = new StringBuilder();
if (includeCollectionColumns) {
// buf.append( selectFragment( lhsAlias, "" ) )//ignore suffix for collection columns!
buf.append(selectFragment(lhsAlias, collectionSuffix)).append(", ");
}
OuterJoinLoadable ojl = (OuterJoinLoadable) getElementPersister();
return // use suffix for the entity columns
buf.append(ojl.selectFragment(lhsAlias, entitySuffix)).toString();
}
Aggregations