use of org.hibernate.sql.results.graph.entity.EntityInitializer in project hibernate-orm by hibernate.
the class CircularFetchImpl method createAssembler.
@Override
public DomainResultAssembler createAssembler(FetchParentAccess parentAccess, AssemblerCreationState creationState) {
final DomainResultAssembler resultAssembler = keyResult.createResultAssembler(parentAccess, creationState);
final EntityInitializer initializer = (EntityInitializer) creationState.resolveInitializer(getNavigablePath(), referencedModelPart, () -> {
if (timing == FetchTiming.IMMEDIATE) {
if (selectByUniqueKey) {
return new EntitySelectFetchByUniqueKeyInitializer(parentAccess, fetchable, getNavigablePath(), entityMappingType.getEntityPersister(), resultAssembler);
}
final EntityPersister entityPersister = entityMappingType.getEntityPersister();
if (entityPersister.isBatchLoadable()) {
return new BatchEntitySelectFetchInitializer(parentAccess, (ToOneAttributeMapping) referencedModelPart, getReferencedPath(), entityPersister, resultAssembler);
} else {
return new EntitySelectFetchInitializer(parentAccess, (ToOneAttributeMapping) referencedModelPart, getReferencedPath(), entityPersister, resultAssembler);
}
} else {
return new EntityDelayedFetchInitializer(parentAccess, getReferencedPath(), fetchable, selectByUniqueKey, resultAssembler);
}
});
return new BiDirectionalFetchAssembler(initializer, fetchable.getJavaType());
}
use of org.hibernate.sql.results.graph.entity.EntityInitializer in project hibernate-orm by hibernate.
the class AbstractEmbeddableInitializer method determineParentInstance.
private Object determineParentInstance(RowProcessingState processingState) {
// or at least the fetch-parent of the collection could get passed.
if (fetchParentAccess != null) {
// the embeddable being initialized is a fetch, so use the fetchParentAccess
// to get the parent reference
//
// at the moment, this uses the legacy behavior of injecting the "first
// containing entity" as the parent. however,
// todo (6.x) - allow injection of containing composite as parent if
// it is the direct parent
final FetchParentAccess firstEntityDescriptorAccess = fetchParentAccess.findFirstEntityDescriptorAccess();
return firstEntityDescriptorAccess.getInitializedInstance();
}
// Otherwise, fallback to determining the parent-initializer by path
// todo (6.0) - this is the part that should be "subsumed" based on the
// comment above
final NavigablePath parentPath = navigablePath.getParent();
if (parentPath == null) {
return null;
}
final Initializer parentInitializer = processingState.resolveInitializer(parentPath);
if (parentInitializer instanceof CollectionInitializer) {
return ((CollectionInitializer) parentInitializer).getCollectionInstance().getOwner();
}
if (parentInitializer instanceof EntityInitializer) {
return ((EntityInitializer) parentInitializer).getEntityInstance();
}
throw new NotYetImplementedFor6Exception(getClass());
}
use of org.hibernate.sql.results.graph.entity.EntityInitializer in project hibernate-orm by hibernate.
the class EntityDelayedFetchImpl method createAssembler.
@Override
public DomainResultAssembler createAssembler(FetchParentAccess parentAccess, AssemblerCreationState creationState) {
final NavigablePath navigablePath = getNavigablePath();
final EntityInitializer entityInitializer = (EntityInitializer) creationState.resolveInitializer(navigablePath, getEntityValuedModelPart(), () -> new EntityDelayedFetchInitializer(parentAccess, navigablePath, (ToOneAttributeMapping) getEntityValuedModelPart(), selectByUniqueKey, keyResult.createResultAssembler(parentAccess, creationState)));
return new EntityAssembler(getFetchedMapping().getJavaType(), entityInitializer);
}
Aggregations