hibernate/hibernate-orm · error · HibernateException

Error performing isolated work

Error message

Error performing isolated work

What it means

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.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/resource/transaction/backend/jta/internal/JtaIsolationDelegate.java:210

			// obtain our isolated connection
			connection = connectionAccess.obtainConnection();
		}
		catch ( SQLException sqle ) {
			throw convert( sqle, "Unable to obtain isolated JDBC connection"  );
		}

		try {
			// do the actual work
			return work.accept( new WorkExecutor<>(), connection );
		}
		catch ( HibernateException he ) {
			throw he;
		}
		catch (SQLException sqle) {
			throw convert( sqle, "Error performing isolated work" );
		}
		catch ( Exception e ) {
			throw new HibernateException( "Error performing isolated work", e );
		}
		finally {
			// no matter what, release the connection (handle)
			releaseConnection( connection );
		}
	}

	private void releaseConnection(Connection connection) {
		try {
			connectionAccess.releaseConnection( connection );
		}
		catch ( Throwable throwable ) {
			JTA_LOGGER.unableToReleaseIsolatedConnection( throwable );
		}
	}

	private HibernateException convert(SQLException sqle, String message) {
		final var jdbcException = sqlExceptionConverter.apply( sqle, message );

View on GitHub (pinned to fad1729dce)

Solutions

  1. Read the JDBCException subtype and SQLState from the cause to identify the failing statement (enable SQL logging to capture it)
  2. Create or fix the target object (sequence/table) or correct the mapping (name, schema/catalog qualifiers, allocationSize)
  3. Grant the DB user the required privileges on the generator objects
  4. Point schema validation at the intended database and re-run
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-check an object the isolated work will touch, with a plain JDBC connection
try (Connection c = dataSource.getConnection();
     PreparedStatement ps = c.prepareStatement("select nextval ('order_seq')")) {
    ps.executeQuery();
}
catch (SQLException e) {
    throw new IllegalStateException("isolated work will fail: " + e.getMessage(), e);
}

Try / catch

catch (JDBCException e) {
    SQLException sql = e.getSQLException();
    // convert() already classified it: SQLGrammarException, ConstraintViolationException, ...
    log.error("isolated JDBC work failed [SQLState {}]", sql != null ? sql.getSQLState() : "?", e);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/a06aa7f0fc46ed9a. Report an issue: GitHub.