Search in sources :

Example 6 with OuterJoinLoadable

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()));
}
Also used : OuterJoinLoadable(org.hibernate.persister.entity.OuterJoinLoadable)

Example 7 with OuterJoinLoadable

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));
}
Also used : OuterJoinLoadable(org.hibernate.persister.entity.OuterJoinLoadable) Joinable(org.hibernate.persister.entity.Joinable)

Example 8 with OuterJoinLoadable

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);
        }
    }
}
Also used : OuterJoinLoadable(org.hibernate.persister.entity.OuterJoinLoadable) Joinable(org.hibernate.persister.entity.Joinable) QueryableCollection(org.hibernate.persister.collection.QueryableCollection)

Example 9 with OuterJoinLoadable

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;
}
Also used : Fetch(org.hibernate.engine.profile.Fetch) OuterJoinLoadable(org.hibernate.persister.entity.OuterJoinLoadable) FetchProfile(org.hibernate.engine.profile.FetchProfile)

Example 10 with OuterJoinLoadable

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();
}
Also used : OuterJoinLoadable(org.hibernate.persister.entity.OuterJoinLoadable)

Aggregations

OuterJoinLoadable (org.hibernate.persister.entity.OuterJoinLoadable)22 Joinable (org.hibernate.persister.entity.Joinable)6 UniqueKeyLoadable (org.hibernate.persister.entity.UniqueKeyLoadable)6 AssociationType (org.hibernate.type.AssociationType)5 QueryableCollection (org.hibernate.persister.collection.QueryableCollection)4 SessionFactoryImplementor (org.hibernate.engine.spi.SessionFactoryImplementor)3 Configuration (org.hibernate.cfg.Configuration)2 EntityReturn (org.hibernate.loader.plan.spi.EntityReturn)2 LoadPlan (org.hibernate.loader.plan.spi.LoadPlan)2 AssociationKey (org.hibernate.persister.walking.spi.AssociationKey)2 EncapsulatedCompositeIdResultSetProcessorTest (org.hibernate.test.loadplans.process.EncapsulatedCompositeIdResultSetProcessorTest)2 Test (org.junit.Test)2 Iterator (java.util.Iterator)1 Dialect (org.hibernate.dialect.Dialect)1 FetchStrategy (org.hibernate.engine.FetchStrategy)1 FetchStyle (org.hibernate.engine.FetchStyle)1 Fetch (org.hibernate.engine.profile.Fetch)1 FetchProfile (org.hibernate.engine.profile.FetchProfile)1 CriteriaJoinWalker (org.hibernate.loader.criteria.CriteriaJoinWalker)1 CollectionFetchableElementEntityGraph (org.hibernate.loader.plan.build.internal.returns.CollectionFetchableElementEntityGraph)1