use of org.hibernate.sql.results.graph.collection.CollectionInitializer 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());
}
Aggregations