{"record":{"id":"a06aa7f0fc46ed9a","repo":"hibernate/hibernate-orm","slug":"error-performing-isolated-work-a06aa7","errorCode":null,"errorMessage":"Error performing isolated work","messagePattern":"Error performing isolated work","errorType":"exception","errorClass":"HibernateException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/resource/transaction/backend/jta/internal/JtaIsolationDelegate.java","lineNumber":210,"sourceCode":"\t\t\t// obtain our isolated connection\n\t\t\tconnection = connectionAccess.obtainConnection();\n\t\t}\n\t\tcatch ( SQLException sqle ) {\n\t\t\tthrow convert( sqle, \"Unable to obtain isolated JDBC connection\"  );\n\t\t}\n\n\t\ttry {\n\t\t\t// do the actual work\n\t\t\treturn work.accept( new WorkExecutor<>(), connection );\n\t\t}\n\t\tcatch ( HibernateException he ) {\n\t\t\tthrow he;\n\t\t}\n\t\tcatch (SQLException sqle) {\n\t\t\tthrow convert( sqle, \"Error performing isolated work\" );\n\t\t}\n\t\tcatch ( Exception e ) {\n\t\t\tthrow new HibernateException( \"Error performing isolated work\", e );\n\t\t}\n\t\tfinally {\n\t\t\t// no matter what, release the connection (handle)\n\t\t\treleaseConnection( connection );\n\t\t}\n\t}\n\n\tprivate void releaseConnection(Connection connection) {\n\t\ttry {\n\t\t\tconnectionAccess.releaseConnection( connection );\n\t\t}\n\t\tcatch ( Throwable throwable ) {\n\t\t\tJTA_LOGGER.unableToReleaseIsolatedConnection( throwable );\n\t\t}\n\t}\n\n\tprivate HibernateException convert(SQLException sqle, String message) {\n\t\tfinal var jdbcException = sqlExceptionConverter.apply( sqle, message );","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/resource/transaction/backend/jta/internal/JtaIsolationDelegate.java#L192-L228","documentation":"doTheWork executes WorkExecutorVisitable work on a connection obtained through connectionAccess; a SQLException is converted by the session's SqlExceptionHelper into a JDBCException carrying this message, and any other exception becomes a plain HibernateException. The connection is always released in the finally block, so this error never leaks the isolated connection. It means the isolated JDBC work itself failed at the SQL/driver level.","triggerScenarios":"IsolationDelegate.delegateWork(..., transacted=false), or the work inside a transacted call, throwing SQLException: selecting from a sequence or table that does not exist (ID generators), DDL failing during schema management, permission errors, or the isolated connection failing to serve the work.","commonSituations":"Mapped sequence or generator table missing from the schema; DB user lacking privileges on generator objects; schema tools pointed at the wrong database; driver-level failures on the isolated connection.","solutions":["Read the JDBCException subtype and SQLState from the cause to identify the failing statement (enable SQL logging to capture it)","Create or fix the target object (sequence/table) or correct the mapping (name, schema/catalog qualifiers, allocationSize)","Grant the DB user the required privileges on the generator objects","Point schema validation at the intended database and re-run"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-check an object the isolated work will touch, with a plain JDBC connection\ntry (Connection c = dataSource.getConnection();\n     PreparedStatement ps = c.prepareStatement(\"select nextval ('order_seq')\")) {\n    ps.executeQuery();\n}\ncatch (SQLException e) {\n    throw new IllegalStateException(\"isolated work will fail: \" + e.getMessage(), e);\n}","typeGuard":null,"tryCatchPattern":"catch (JDBCException e) {\n    SQLException sql = e.getSQLException();\n    // convert() already classified it: SQLGrammarException, ConstraintViolationException, ...\n    log.error(\"isolated JDBC work failed [SQLState {}]\", sql != null ? sql.getSQLState() : \"?\", e);\n}","preventionTips":["Run schema validation (hbm2ddl.auto=validate) at startup so missing generator objects fail fast with a clear error","Keep generator object DDL in migrations next to the entity mappings","Grant the DB user privileges on sequences/tables used by generators"],"tags":["jta","hibernate","jdbc","sqlexception","isolation-delegate","id-generation"],"backgroundTag":"sql-execution-failed","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}