hibernate/hibernate-orm · error · UnsupportedOperationException
The Embeddable: %s parent initializer is neither an instance
Error message
The Embeddable: %s parent initializer is neither an instance of an EntityInitializer nor of a CollectionInitializer
What it means
After locating the owning initializer, EmbeddableInitializerImpl.determineParentInstance() can only produce a parent instance from an EntityInitializer (its target instance) or a CollectionInitializer (the collection's owner). If the parent initializer is neither of those kinds, it throws UnsupportedOperationException('The Embeddable: <navigablePath> parent initializer is neither an instance of an EntityInitializer nor of a CollectionInitializer'). It is the companion failure to 'Injection of parent instance into embeddable result is not possible': the embeddable's parent chain resolves to an initializer type that cannot supply an owning instance.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/internal/EmbeddableInitializerImpl.java:580
throw new UnsupportedOperationException( "Injection of parent instance into embeddable result is not possible" );
}
private Object determineParentInstance(Initializer<?> parentInitializer, RowProcessingState rowProcessingState) {
if ( parentInitializer == null ) {
throw new UnsupportedOperationException( "Cannot determine Embeddable: " + navigablePath + " parent instance, parent initializer is null" );
}
final var collectionInitializer = parentInitializer.asCollectionInitializer();
if ( collectionInitializer != null ) {
return collectionInitializer.getCollectionInstance( rowProcessingState ).getOwner();
}
final var parentEntityInitializer = parentInitializer.asEntityInitializer();
if ( parentEntityInitializer != null ) {
return parentEntityInitializer.getTargetInstance( rowProcessingState );
}
throw new UnsupportedOperationException( "The Embeddable: " + navigablePath + " parent initializer is neither an instance of an EntityInitializer nor of a CollectionInitializer" );
}
@Override
public String toString() {
return getClass().getSimpleName() + "(" + navigablePath + ") : "
+ getInitializedPart().getJavaType().getJavaTypeClass().getSimpleName();
}
}
View on GitHub (pinned to fad1729dce)
Solutions
- Restructure the query so the embeddable is reached through its owning entity (fetch/select the owner and traverse from it).
- Replace the embeddable projection with a scalar projection of its attributes or a DTO constructor expression.
- If a custom Initializer/integrator is involved, review its position in the parent chain; an initializer that is neither entity nor collection cannot parent an embeddable.
- Report or upgrade: this path indicates initializer wiring Hibernate does not handle - check the Hibernate JIRA for your version and test on the latest patch release.
Example fix
// before - embeddable reached through a chain Hibernate cannot parent
em.createQuery("select o.customer.contact.info from Order o", ContactInfo.class).getResultList();
// after - own the projection with a DTO
em.createQuery(
"select new com.acme.ContactDto(i.email, i.phone) from Order o join o.customer.contact.info i",
ContactDto.class).getResultList(); Defensive patterns
Strategy: try-catch
Try / catch
try {
results = query.getResultList();
} catch (UnsupportedOperationException e) {
if (String.valueOf(e.getMessage()).contains("neither an instance of an EntityInitializer")) {
// fall back to selecting the owning entity and traversing in Java
} else { throw e; }
} Prevention
- Reach embeddables through their owning entity in queries rather than deep projection paths.
- Avoid custom Initializer implementations parenting embeddables unless they are entity or collection initializers.
- Add a smoke test per query after any Hibernate version bump.
When it happens
Trigger: An embeddable fetch whose resolved parent initializer is some other Initializer implementation - typically another embeddable/composite initializer that slipped through the determineOwningInitializer() walk, or an initializer contributed by custom user types, Hibernate Reactive, or third-party integrations that are not entity or collection initializers.
Common situations: Deeply nested embeddables used in unusual query positions; custom Initializer implementations registered via integrators; edge cases after a 6.x upgrade where initializer wiring changed; entity graphs or fetch profiles that restructure the initializer tree.
Related errors
- Injection of parent instance into embeddable result is not p
- Embeddable class not found: {}
- component: {} property not found: {}
- component type [{}] specifies {} properties for the instanti
- could not find property [{}] defined in the @Instantiator wi
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/797a123171e1cc75.
Report an issue: GitHub.