Search in sources :

Example 1 with ExpandingCompositeQuerySpace

use of org.hibernate.loader.plan.build.spi.ExpandingCompositeQuerySpace 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 ExpandingCompositeQuerySpace

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

the class AbstractEntityReference method buildIdentifierDescription.

/**
	 * Builds just the first level of identifier description.  This will be either a simple id descriptor (String,
	 * Long, etc) or some form of composite id (either encapsulated or not).
	 *
	 * @return the descriptor for the identifier
	 */
private EntityIdentifierDescription buildIdentifierDescription() {
    final EntityIdentifierDefinition identifierDefinition = getEntityPersister().getEntityKeyDefinition();
    if (identifierDefinition.isEncapsulated()) {
        final EncapsulatedEntityIdentifierDefinition encapsulatedIdentifierDefinition = (EncapsulatedEntityIdentifierDefinition) identifierDefinition;
        final Type idAttributeType = encapsulatedIdentifierDefinition.getAttributeDefinition().getType();
        if (!CompositeType.class.isInstance(idAttributeType)) {
            return new SimpleEntityIdentifierDescriptionImpl();
        }
    }
    // if we get here, we know we have a composite identifier...
    final ExpandingCompositeQuerySpace querySpace = expandingEntityQuerySpace().makeCompositeIdentifierQuerySpace();
    return identifierDefinition.isEncapsulated() ? buildEncapsulatedCompositeIdentifierDescription(querySpace) : buildNonEncapsulatedCompositeIdentifierDescription(querySpace);
}
Also used : ExpandingCompositeQuerySpace(org.hibernate.loader.plan.build.spi.ExpandingCompositeQuerySpace) CompositeType(org.hibernate.type.CompositeType) Type(org.hibernate.type.Type) EncapsulatedEntityIdentifierDefinition(org.hibernate.persister.walking.spi.EncapsulatedEntityIdentifierDefinition) EncapsulatedEntityIdentifierDefinition(org.hibernate.persister.walking.spi.EncapsulatedEntityIdentifierDefinition) EntityIdentifierDefinition(org.hibernate.persister.walking.spi.EntityIdentifierDefinition) CompositeType(org.hibernate.type.CompositeType)

Example 3 with ExpandingCompositeQuerySpace

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

the class AbstractExpandingFetchSource method buildCompositeAttributeFetch.

@Override
public CompositeAttributeFetch buildCompositeAttributeFetch(AttributeDefinition attributeDefinition) {
    final ExpandingCompositeQuerySpace compositeQuerySpace = QuerySpaceHelper.INSTANCE.makeCompositeQuerySpace(expandingQuerySpace(), attributeDefinition, getQuerySpaces().generateImplicitUid(), true);
    final CompositeAttributeFetch fetch = createCompositeAttributeFetch(attributeDefinition, compositeQuerySpace);
    addFetch(fetch);
    return fetch;
}
Also used : ExpandingCompositeQuerySpace(org.hibernate.loader.plan.build.spi.ExpandingCompositeQuerySpace) CompositeAttributeFetch(org.hibernate.loader.plan.spi.CompositeAttributeFetch)

Example 4 with ExpandingCompositeQuerySpace

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

the class EntityQuerySpaceImpl method makeCompositeIdentifierQuerySpace.

@Override
public ExpandingCompositeQuerySpace makeCompositeIdentifierQuerySpace() {
    final String compositeQuerySpaceUid = getUid() + "-id";
    final ExpandingCompositeQuerySpace rhs = getExpandingQuerySpaces().makeCompositeQuerySpace(compositeQuerySpaceUid, new CompositePropertyMapping((CompositeType) getEntityPersister().getIdentifierType(), (PropertyMapping) getEntityPersister(), getEntityPersister().getIdentifierPropertyName()), canJoinsBeRequired());
    final JoinDefinedByMetadata join = JoinHelper.INSTANCE.createCompositeJoin(this, EntityPersister.ENTITY_ID, rhs, canJoinsBeRequired(), (CompositeType) persister.getIdentifierType());
    internalGetJoins().add(join);
    return rhs;
}
Also used : ExpandingCompositeQuerySpace(org.hibernate.loader.plan.build.spi.ExpandingCompositeQuerySpace) PropertyMapping(org.hibernate.persister.entity.PropertyMapping) JoinDefinedByMetadata(org.hibernate.loader.plan.spi.JoinDefinedByMetadata) CompositeType(org.hibernate.type.CompositeType)

Example 5 with ExpandingCompositeQuerySpace

use of org.hibernate.loader.plan.build.spi.ExpandingCompositeQuerySpace 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)

Aggregations

ExpandingCompositeQuerySpace (org.hibernate.loader.plan.build.spi.ExpandingCompositeQuerySpace)7 CompositeType (org.hibernate.type.CompositeType)4 Type (org.hibernate.type.Type)3 CompositePropertyMapping (org.hibernate.loader.plan.build.internal.spaces.CompositePropertyMapping)2 ExpandingEntityQuerySpace (org.hibernate.loader.plan.build.spi.ExpandingEntityQuerySpace)2 JoinDefinedByMetadata (org.hibernate.loader.plan.spi.JoinDefinedByMetadata)2 CollectionPersister (org.hibernate.persister.collection.CollectionPersister)2 EntityPersister (org.hibernate.persister.entity.EntityPersister)2 EntityType (org.hibernate.type.EntityType)2 CompositeAttributeFetch (org.hibernate.loader.plan.spi.CompositeAttributeFetch)1 PropertyMapping (org.hibernate.persister.entity.PropertyMapping)1 EncapsulatedEntityIdentifierDefinition (org.hibernate.persister.walking.spi.EncapsulatedEntityIdentifierDefinition)1 EntityIdentifierDefinition (org.hibernate.persister.walking.spi.EntityIdentifierDefinition)1