{"record":{"id":"a8e840b86ba0093e","repo":"hibernate/hibernate-orm","slug":"could-not-determine-transaction-status-in-beforeco","errorCode":null,"errorMessage":"could not determine transaction status in beforeCompletion()","messagePattern":"could not determine transaction status in beforeCompletion\\(\\)","errorType":"exception","errorClass":"HibernateException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/internal/StatelessSessionImpl.java","lineNumber":1800,"sourceCode":"\tpublic TransactionCompletionCallbacks getTransactionCompletionCallbacks() {\n\t\treturn transactionCompletionCallbacks;\n\t}\n\n\t@Override\n\tpublic void flushBeforeTransactionCompletion() {\n\t\tif ( shouldFlushBeforeCompletion() ) {\n\t\t\tmanagedFlush();\n\t\t}\n\t}\n\n\tprivate boolean shouldFlushBeforeCompletion() {\n\t\ttry {\n\t\t\treturn !isClosed()\n\t\t\t\t&& !isFlushModeNever()\n\t\t\t\t&& !isRollback( getJtaPlatform().getCurrentStatus() );\n\t\t}\n\t\tcatch ( SystemException se ) {\n\t\t\tthrow new HibernateException( \"could not determine transaction status in beforeCompletion()\", se );\n\t\t}\n\t}\n\n\tprivate JtaPlatform getJtaPlatform() {\n\t\treturn getFactory().getServiceRegistry().requireService( JtaPlatform.class );\n\t}\n\n\tprivate LockMode getNullSafeLockMode(LockMode lockMode) {\n\t\treturn lockMode == null ? LockMode.NONE : lockMode;\n\t}\n\n\tprotected Object lockCacheItem(Object id, Object previousVersion, EntityPersister persister) {\n\t\treturn writingToCache( persister, cache -> {\n\t\t\tfinal Object cacheKey = cache.generateCacheKey(\n\t\t\t\t\tid,\n\t\t\t\t\tpersister,\n\t\t\t\t\tgetFactory(),\n\t\t\t\t\tgetTenantIdentifier()","sourceCodeStart":1782,"sourceCodeEnd":1818,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/internal/StatelessSessionImpl.java#L1782-L1818","documentation":"Error \"could not determine transaction status in beforeCompletion()\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Thrown at hibernate-core/src/main/java/org/hibernate/internal/StatelessSessionImpl.java:1800 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the transaction is still active in beforeCompletion(); avoid completing/rolling back the transaction before synchronization callbacks run.","Check transaction status via Transaction.getStatus() before operations in afterBegin/beforeCompletion."],"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"}