{"record":{"id":"7d1a74f9c9137b8d","repo":"hibernate/hibernate-orm","slug":"persistent-instance-of-entityname-with-id","errorCode":null,"errorMessage":"Persistent instance of '${entityName}' with id [${id}] references an unsaved transient instance of '${transientEntityName}' (persist the transient instance before flushing)","messagePattern":"Persistent instance of '(.+?)' with id \\[(.+?)\\] 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/ActionQueueLegacy.java","lineNumber":498,"sourceCode":"\t\t}\n\t}\n\n\t/**\n\t * Perform all currently queued actions.\n\t *\n\t * @throws HibernateException error executing queued actions.\n\t */\n\tpublic void executeActions() throws HibernateException {\n\t\tif ( hasUnresolvedEntityInsertActions() ) {\n\t\t\tfinal var insertAction =\n\t\t\t\t\tunresolvedInsertions.getDependentEntityInsertActions()\n\t\t\t\t\t\t\t.iterator().next();\n\t\t\tfinal var transientEntities = insertAction.findNonNullableTransientEntities();\n\t\t\tfinal Object transientEntity = transientEntities.getNonNullableTransientEntities().iterator().next();\n\t\t\tfinal String path = transientEntities.getNonNullableTransientPropertyPaths( transientEntity ).iterator().next();\n\t\t\tfinal String transientEntityName = session.bestGuessEntityName( transientEntity );\n\t\t\tfinal String entityName = insertAction.getEntityName();\n\t\t\tthrow new TransientPropertyValueException(\n\t\t\t\t\t\"Persistent instance of '\" + entityName + \"' with id [\" + insertAction.getId()\n\t\t\t\t\t+ \"] references an unsaved transient instance of '\" + transientEntityName\n\t\t\t\t\t+ \"' (persist the transient instance before flushing)\",\n\t\t\t\t\tentityName,\n\t\t\t\t\ttransientEntityName,\n\t\t\t\t\tpath );\n\t\t}\n\n\t\tfor ( var action : ORDERED_OPERATIONS ) {\n\t\t\texecuteActions( action.getActions( this ) );\n\t\t}\n\t}\n\n\t/**\n\t * Prepares the internal action queues for execution.\n\t *\n\t * @throws HibernateException error preparing actions.\n\t */","sourceCodeStart":480,"sourceCodeEnd":516,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/engine/spi/ActionQueueLegacy.java#L480-L516","documentation":"Error \"Persistent instance of '${entityName}' with id [${id}] references an unsaved transient instance of '${transientEntityName}' (persist the transient instance before flushing)\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Thrown at hibernate-core/src/main/java/org/hibernate/engine/spi/ActionQueueLegacy.java:498 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Persist the transient child instance before flushing the parent","Add cascade=PERSIST (or ALL) on the association from parent to child"],"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-22T14:17:55.899Z"}