{"record":{"id":"380aaecca8a62a79","repo":"hibernate/hibernate-orm","slug":"persistent-instance-of-parententityname-refer","errorCode":null,"errorMessage":"Persistent instance of '${parentEntityName}' references an unsaved transient instance of '${childEntityName}' (persist the transient instance before flushing)","messagePattern":"Persistent instance of '(.+?)' references an unsaved transient instance of '(.+?)' \\(persist the transient instance before flushing\\)","errorType":"exception","errorClass":"TransientPropertyValueException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/engine/spi/CascadingActions.java","lineNumber":383,"sourceCode":"\t// this is not a real type of cascade, but it's a check that\n\t// is at least a bit sensitive to the cascade style, and it's\n\t// convenient to be able to use the graph-walking logic that\n\t// is already implemented in the Cascade class (though perhaps\n\t// we could reuse the logic in Nullability instead)\n\tpublic static final CascadingAction<Void> CHECK_ON_FLUSH = new BaseCascadingAction<>() {\n\t\t@Override\n\t\tpublic void cascade(\n\t\t\t\tEventSource session,\n\t\t\t\tObject child,\n\t\t\t\tString childEntityName,\n\t\t\t\tString parentEntityName,\n\t\t\t\tString propertyName,\n\t\t\t\t@Nullable List<String> attributePath,\n\t\t\t\tVoid nothing,\n\t\t\t\tboolean isCascadeDeleteEnabled)\n\t\t\t\tthrows HibernateException {\n\t\t\tif ( child != null && isChildTransient( session, child, childEntityName, isCascadeDeleteEnabled ) ) {\n\t\t\t\tthrow new TransientPropertyValueException(\n\t\t\t\t\t\t\"Persistent instance of '\" + parentEntityName\n\t\t\t\t\t\t\t+ \"' references an unsaved transient instance of '\" + childEntityName\n\t\t\t\t\t\t\t+ \"' (persist the transient instance before flushing)\",\n\t\t\t\t\t\tchildEntityName,\n\t\t\t\t\t\tparentEntityName,\n\t\t\t\t\t\tattributePath == null\n\t\t\t\t\t\t\t\t? propertyName\n\t\t\t\t\t\t\t\t: join( \".\", attributePath ) + '.' + propertyName\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t@Override\n\t\tpublic Iterator<?> getCascadableChildrenIterator(\n\t\t\t\tEventSource session,\n\t\t\t\tCollectionType collectionType,\n\t\t\t\tObject collection) {\n\t\t\tif ( collectionType.isInverse( session.getSessionFactory() ) ) {","sourceCodeStart":365,"sourceCodeEnd":401,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/engine/spi/CascadingActions.java#L365-L401","documentation":"Error \"Persistent instance of '${parentEntityName}' references an unsaved transient instance of '${childEntityName}' (persist the transient instance before flushing)\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Thrown at hibernate-core/src/main/java/org/hibernate/engine/spi/CascadingActions.java:383 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Persist the transient child before flushing the parent entity","Configure cascading so the child is persisted automatically"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}