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