{"record":{"id":"797a123171e1cc75","repo":"hibernate/hibernate-orm","slug":"the-embeddable-s-parent-initializer-is-neither-a","errorCode":null,"errorMessage":"The Embeddable: %s parent initializer is neither an instance of an EntityInitializer nor of a CollectionInitializer","messagePattern":"The Embeddable: (.+?) parent initializer is neither an instance of an EntityInitializer nor of a CollectionInitializer","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/internal/EmbeddableInitializerImpl.java","lineNumber":580,"sourceCode":"\t\tthrow new UnsupportedOperationException( \"Injection of parent instance into embeddable result is not possible\" );\n\t}\n\n\tprivate Object determineParentInstance(Initializer<?> parentInitializer, RowProcessingState rowProcessingState) {\n\t\tif ( parentInitializer == null ) {\n\t\t\tthrow new UnsupportedOperationException( \"Cannot determine Embeddable: \" + navigablePath + \" parent instance, parent initializer is null\" );\n\t\t}\n\n\t\tfinal var collectionInitializer = parentInitializer.asCollectionInitializer();\n\t\tif ( collectionInitializer != null ) {\n\t\t\treturn collectionInitializer.getCollectionInstance( rowProcessingState ).getOwner();\n\t\t}\n\n\t\tfinal var parentEntityInitializer = parentInitializer.asEntityInitializer();\n\t\tif ( parentEntityInitializer != null ) {\n\t\t\treturn parentEntityInitializer.getTargetInstance( rowProcessingState );\n\t\t}\n\n\t\tthrow new UnsupportedOperationException( \"The Embeddable: \" + navigablePath + \" parent initializer is neither an instance of an EntityInitializer nor of a CollectionInitializer\" );\n\t}\n\n\t@Override\n\tpublic String toString() {\n\t\treturn getClass().getSimpleName() + \"(\" + navigablePath + \") : \"\n\t\t\t+ getInitializedPart().getJavaType().getJavaTypeClass().getSimpleName();\n\t}\n}\n","sourceCodeStart":562,"sourceCodeEnd":589,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/internal/EmbeddableInitializerImpl.java#L562-L589","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before - embeddable reached through a chain Hibernate cannot parent\nem.createQuery(\"select o.customer.contact.info from Order o\", ContactInfo.class).getResultList();\n\n// after - own the projection with a DTO\nem.createQuery(\n  \"select new com.acme.ContactDto(i.email, i.phone) from Order o join o.customer.contact.info i\",\n  ContactDto.class).getResultList();","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    results = query.getResultList();\n} catch (UnsupportedOperationException e) {\n    if (String.valueOf(e.getMessage()).contains(\"neither an instance of an EntityInitializer\")) {\n        // fall back to selecting the owning entity and traversing in Java\n    } else { throw e; }\n}","preventionTips":["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."],"tags":["hibernate","orm","embeddable","initializer","unsupported-operation"],"backgroundTag":"embeddable-parent-injection","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}