Search in sources :

Example 1 with ExpandingEntityQuerySpace

use of org.hibernate.loader.plan.build.spi.ExpandingEntityQuerySpace in project hibernate-orm by hibernate.

the class AbstractCollectionReference method buildElementGraph.

private CollectionFetchableElement buildElementGraph() {
    final CollectionPersister persister = collectionQuerySpace.getCollectionPersister();
    final Type type = persister.getElementType();
    if (type.isAssociationType()) {
        if (type.isEntityType()) {
            final EntityPersister elementPersister = persister.getFactory().getEntityPersister(((EntityType) type).getAssociatedEntityName());
            final ExpandingEntityQuerySpace entityQuerySpace = QuerySpaceHelper.INSTANCE.makeEntityQuerySpace(collectionQuerySpace, elementPersister, CollectionPropertyNames.COLLECTION_ELEMENTS, (EntityType) persister.getElementType(), collectionQuerySpace.getExpandingQuerySpaces().generateImplicitUid(), collectionQuerySpace.canJoinsBeRequired(), allowElementJoin);
            return new CollectionFetchableElementEntityGraph(this, entityQuerySpace);
        } else if (type.isAnyType()) {
            return new CollectionFetchableElementAnyGraph(this);
        }
    } else if (type.isComponentType()) {
        final ExpandingCompositeQuerySpace compositeQuerySpace = QuerySpaceHelper.INSTANCE.makeCompositeQuerySpace(collectionQuerySpace, new CompositePropertyMapping((CompositeType) persister.getElementType(), (PropertyMapping) persister, ""), CollectionPropertyNames.COLLECTION_ELEMENTS, (CompositeType) persister.getElementType(), collectionQuerySpace.getExpandingQuerySpaces().generateImplicitUid(), collectionQuerySpace.canJoinsBeRequired(), allowElementJoin);
        return new CollectionFetchableElementCompositeGraph(this, compositeQuerySpace);
    }
    return null;
}
Also used : EntityPersister(org.hibernate.persister.entity.EntityPersister) ExpandingCompositeQuerySpace(org.hibernate.loader.plan.build.spi.ExpandingCompositeQuerySpace) EntityType(org.hibernate.type.EntityType) CompositeType(org.hibernate.type.CompositeType) Type(org.hibernate.type.Type) CollectionPersister(org.hibernate.persister.collection.CollectionPersister) CompositePropertyMapping(org.hibernate.loader.plan.build.internal.spaces.CompositePropertyMapping) ExpandingEntityQuerySpace(org.hibernate.loader.plan.build.spi.ExpandingEntityQuerySpace) CompositeType(org.hibernate.type.CompositeType)

Example 2 with ExpandingEntityQuerySpace

use of org.hibernate.loader.plan.build.spi.ExpandingEntityQuerySpace in project hibernate-orm by hibernate.

the class QuerySpacesImpl method makeRootEntityQuerySpace.

@Override
public ExpandingEntityQuerySpace makeRootEntityQuerySpace(String uid, EntityPersister entityPersister) {
    final ExpandingEntityQuerySpace space = makeEntityQuerySpace(uid, entityPersister, true);
    roots.add(space);
    return space;
}
Also used : ExpandingEntityQuerySpace(org.hibernate.loader.plan.build.spi.ExpandingEntityQuerySpace)

Example 3 with ExpandingEntityQuerySpace

use of org.hibernate.loader.plan.build.spi.ExpandingEntityQuerySpace in project hibernate-orm by hibernate.

the class AbstractCollectionReference method buildIndexGraph.

private CollectionFetchableIndex buildIndexGraph() {
    final CollectionPersister persister = collectionQuerySpace.getCollectionPersister();
    if (persister.hasIndex()) {
        final Type type = persister.getIndexType();
        if (type.isAssociationType()) {
            if (type.isEntityType()) {
                final EntityPersister indexPersister = persister.getFactory().getEntityPersister(((EntityType) type).getAssociatedEntityName());
                final ExpandingEntityQuerySpace entityQuerySpace = QuerySpaceHelper.INSTANCE.makeEntityQuerySpace(collectionQuerySpace, indexPersister, CollectionPropertyNames.COLLECTION_INDICES, (EntityType) persister.getIndexType(), collectionQuerySpace.getExpandingQuerySpaces().generateImplicitUid(), collectionQuerySpace.canJoinsBeRequired(), allowIndexJoin);
                return new CollectionFetchableIndexEntityGraph(this, entityQuerySpace);
            } else if (type.isAnyType()) {
                return new CollectionFetchableIndexAnyGraph(this);
            }
        } else if (type.isComponentType()) {
            final ExpandingCompositeQuerySpace compositeQuerySpace = QuerySpaceHelper.INSTANCE.makeCompositeQuerySpace(collectionQuerySpace, new CompositePropertyMapping((CompositeType) persister.getIndexType(), (PropertyMapping) persister, ""), CollectionPropertyNames.COLLECTION_INDICES, (CompositeType) persister.getIndexType(), collectionQuerySpace.getExpandingQuerySpaces().generateImplicitUid(), collectionQuerySpace.canJoinsBeRequired(), allowIndexJoin);
            return new CollectionFetchableIndexCompositeGraph(this, compositeQuerySpace);
        }
    }
    return null;
}
Also used : EntityPersister(org.hibernate.persister.entity.EntityPersister) ExpandingCompositeQuerySpace(org.hibernate.loader.plan.build.spi.ExpandingCompositeQuerySpace) EntityType(org.hibernate.type.EntityType) CompositeType(org.hibernate.type.CompositeType) Type(org.hibernate.type.Type) CollectionPersister(org.hibernate.persister.collection.CollectionPersister) CompositePropertyMapping(org.hibernate.loader.plan.build.internal.spaces.CompositePropertyMapping) ExpandingEntityQuerySpace(org.hibernate.loader.plan.build.spi.ExpandingEntityQuerySpace) CompositeType(org.hibernate.type.CompositeType)

Example 4 with ExpandingEntityQuerySpace

use of org.hibernate.loader.plan.build.spi.ExpandingEntityQuerySpace in project hibernate-orm by hibernate.

the class AbstractExpandingFetchSource method buildEntityAttributeFetch.

@Override
public EntityFetch buildEntityAttributeFetch(AssociationAttributeDefinition attributeDefinition, FetchStrategy fetchStrategy) {
    final ExpandingEntityQuerySpace entityQuerySpace = QuerySpaceHelper.INSTANCE.makeEntityQuerySpace(expandingQuerySpace(), attributeDefinition, getQuerySpaces().generateImplicitUid(), fetchStrategy);
    final EntityFetch fetch = new EntityAttributeFetchImpl(this, attributeDefinition, fetchStrategy, entityQuerySpace);
    addFetch(fetch);
    return fetch;
}
Also used : EntityFetch(org.hibernate.loader.plan.spi.EntityFetch) ExpandingEntityQuerySpace(org.hibernate.loader.plan.build.spi.ExpandingEntityQuerySpace)

Example 5 with ExpandingEntityQuerySpace

use of org.hibernate.loader.plan.build.spi.ExpandingEntityQuerySpace in project hibernate-orm by hibernate.

the class QuerySpaceHelper method makeEntityQuerySpace.

public ExpandingEntityQuerySpace makeEntityQuerySpace(ExpandingQuerySpace lhsQuerySpace, EntityPersister fetchedPersister, String attributeName, EntityType attributeType, String querySpaceUid, boolean required, boolean shouldIncludeJoin) {
    final ExpandingEntityQuerySpace rhs = lhsQuerySpace.getExpandingQuerySpaces().makeEntityQuerySpace(querySpaceUid, fetchedPersister, required);
    if (shouldIncludeJoin) {
        final JoinDefinedByMetadata join = JoinHelper.INSTANCE.createEntityJoin(lhsQuerySpace, attributeName, rhs, required, attributeType, fetchedPersister.getFactory());
        lhsQuerySpace.addJoin(join);
    }
    return rhs;
}
Also used : JoinDefinedByMetadata(org.hibernate.loader.plan.spi.JoinDefinedByMetadata) ExpandingEntityQuerySpace(org.hibernate.loader.plan.build.spi.ExpandingEntityQuerySpace)

Aggregations

ExpandingEntityQuerySpace (org.hibernate.loader.plan.build.spi.ExpandingEntityQuerySpace)5 CompositePropertyMapping (org.hibernate.loader.plan.build.internal.spaces.CompositePropertyMapping)2 ExpandingCompositeQuerySpace (org.hibernate.loader.plan.build.spi.ExpandingCompositeQuerySpace)2 CollectionPersister (org.hibernate.persister.collection.CollectionPersister)2 EntityPersister (org.hibernate.persister.entity.EntityPersister)2 CompositeType (org.hibernate.type.CompositeType)2 EntityType (org.hibernate.type.EntityType)2 Type (org.hibernate.type.Type)2 EntityFetch (org.hibernate.loader.plan.spi.EntityFetch)1 JoinDefinedByMetadata (org.hibernate.loader.plan.spi.JoinDefinedByMetadata)1