hibernate/hibernate-orm · critical · HibernateException

Error performing isolated work

Error message

Error performing isolated work

What it means

HibernateException from JdbcIsolationDelegate: work executed in its own isolated JDBC transaction — separate from the current one — failed with a SQLException that the SqlExceptionHelper converted with this generic message. This delegate backs isolated internal work such as table-based ID generator segment reads, sequence information extraction, and similar single-shot database helper operations.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/resource/transaction/backend/jdbc/internal/JdbcIsolationDelegate.java:75

				wasAutoCommit = disableAutoCommit( transacted, connection );
			}
			catch (SQLException sqle) {
				throw sqlExceptionHelper.convert( sqle, "Unable to manage autocommit on isolated JDBC connection" );
			}

			try {
				return doWorkAndCommit( work, transacted, connection );
			}
			catch (Exception exception) {
				rollBack( transacted, connection, exception );
				if ( exception instanceof HibernateException he ) {
					throw he;
				}
				else if ( exception instanceof SQLException sqle ) {
					throw sqlExceptionHelper.convert( sqle, "Error performing isolated work" );
				}
				else {
					throw new HibernateException( "Error performing isolated work", exception );
				}
			}
			finally {
				resetAutoCommit( transacted, wasAutoCommit, connection );
			}
		}
		finally {
			releaseConnection( connection );
		}
	}

	private static <T> T doWorkAndCommit(WorkExecutorVisitable<T> work, boolean transacted, Connection connection)
			throws SQLException {
		T result = work.accept( new WorkExecutor<>(), connection );
		if ( transacted ) {
			connection.commit();
		}
		return result;

View on GitHub (pinned to fad1729dce)

Solutions

  1. Read the converted cause (SQLException + actual SQL) to see exactly which statement and object failed
  2. Create or fix the backing object: e.g. CREATE TABLE for the @TableGenerator table (with its pk/value columns and seed row) or CREATE SEQUENCE hibernate_sequence
  3. Grant the DB user the needed privileges on that object
  4. Validate the mapping against the schema: table/sequence names, pkColumnName/valueColumnName, allocationSize

Example fix

// before
@TableGenerator(name = "ids", table = "gen_table", pkColumnName = "k", valueColumnName = "v")
// gen_table never created -> 'Error performing isolated work' on first persist

// after
// migration (run once):
// CREATE TABLE gen_table (k VARCHAR(64) PRIMARY KEY, v BIGINT NOT NULL);
// INSERT INTO gen_table (k, v) VALUES ('ids', 0);
Defensive patterns

Strategy: try-catch

Validate before calling

// PostgreSQL: verify the generator object exists before the first insert
try (Connection c = dataSource.getConnection();
     PreparedStatement ps = c.prepareStatement(
         "select 1 from information_schema.sequences where sequence_name = 'hibernate_sequence'")) {
  if (!ps.executeQuery().next()) {
    throw new IllegalStateException("hibernate_sequence is missing");
  }
}

Type guard

static SQLException findSqlException(Throwable t) {
  for (Throwable c = t; c != null; c = c.getCause()) {
    if (c instanceof SQLException s) return s;
  }
  return null;
}

Try / catch

try {
  em.persist(entity);
  em.flush();
} catch (org.hibernate.HibernateException e) {
  SQLException sql = findSqlException(e); // 'Error performing isolated work'
  // inspect sql + statement, then fix the schema object (create/grant) rather than retrying blindly
}

Prevention

When it happens

Trigger: An entity uses a table-based generator (or another component that runs isolated work) and the isolated SELECT/UPDATE fails: the generator table or sequence does not exist, the DB user lacks privileges on it, the mapping names the wrong table/sequence, or the isolated connection itself cannot reach the DB. Typically surfaces on the first insert after startup.

Common situations: Schema created without hibernate_sequence / the @TableGenerator table; @TableGenerator pointing at a wrong table or pkColumn/valueColumn names; migrations that renamed sequences (Oracle/PostgreSQL); read-restricted DB users missing SELECT/UPDATE grants on the generator object.

Related errors


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