hibernate/hibernate-orm · error · SchemaManagementException
User-provided Connection via JdbcConnectionAccessProvidedCon
Error message
User-provided Connection via JdbcConnectionAccessProvidedConnectionImpl has wrong auto-commit mode
What it means
Schema tooling running on a user-provided Connection (DdlTransactionIsolatorProvidedConnectionImpl) obtained the connection and found its auto-commit mode different from the mode the tool requires (getIsolatedConnection(autocommit) - GenerationTargetToDatabase passes its needsAutoCommit flag here). Hibernate executes DDL statement-by-statement on that connection and requires the mode to match exactly, so it refuses to proceed with a mismatched connection.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/tool/schema/internal/DdlTransactionIsolatorProvidedConnectionImpl.java:46
this.jdbcContext = jdbcContext;
}
@Override
public JdbcContext getJdbcContext() {
return jdbcContext;
}
@Override
public Connection getIsolatedConnection() {
return getIsolatedConnection(true);
}
@Override
public Connection getIsolatedConnection(boolean autocommit) {
try {
Connection connection = jdbcContext.getJdbcConnectionAccess().obtainConnection();
if ( connection.getAutoCommit() != autocommit ) {
throw new SchemaManagementException( "User-provided Connection via JdbcConnectionAccessProvidedConnectionImpl has wrong auto-commit mode" );
}
return connection;
}
catch (SQLException e) {
// should never happen
throw new SchemaManagementException( "Error accessing user-provided Connection via JdbcConnectionAccessProvidedConnectionImpl", e );
}
}
@Override
public void release() {
final var connectionAccess = jdbcContext.getJdbcConnectionAccess();
if( !( connectionAccess instanceof JdbcConnectionAccessProvidedConnectionImpl ) ) {
throw new IllegalStateException(
"DdlTransactionIsolatorProvidedConnectionImpl should always use a JdbcConnectionAccessProvidedConnectionImpl"
);
}
try {View on GitHub (pinned to fad1729dce)
Solutions
- Set connection.setAutoCommit(true) on the provided connection before handing it to the schema tool when it requires autocommit mode.
- Or configure the DataSource/pool used for the schema run (e.g. Hikari autoCommit setting) to the mode the tool requests.
- Better: let Hibernate manage its own connection/transaction isolator (configure the connection provider) instead of supplying a raw connection for DDL.
- If you need transactional DDL, run the statements yourself on your own connection rather than through the schema tool.
Example fix
// before: pool default autoCommit=false, schema tool requires autocommit Connection conn = dataSource.getConnection(); // HikariCP default: autoCommit=false new SchemaExport(metadata).execute(targets, Action.BOTH, metadata, registry); // after: align the mode for the connection handed to the tool Connection conn = dataSource.getConnection(); conn.setAutoCommit(true); new SchemaExport(metadata).execute(targets, Action.BOTH, metadata, registry);
Defensive patterns
Strategy: validation
Validate before calling
// Before handing a connection to the schema tool, align its auto-commit mode with what the tool requests
Connection conn = dataSource.getConnection();
if (!conn.getAutoCommit()) {
conn.setAutoCommit(true); // schema tool executes DDL statement-by-statement with autocommit
} Try / catch
try {
new SchemaExport(metadata).execute(targets, Action.CREATE, metadata, registry);
} catch (SchemaManagementException e) {
if ("User-provided Connection via JdbcConnectionAccessProvidedConnectionImpl has wrong auto-commit mode".equals(e.getMessage())) {
// set the requested autoCommit mode on the provided connection and retry once
}
throw e;
} Prevention
- Dedicate a schema-tooling connection with autocommit enabled rather than reusing transactional pool connections
- Check pool defaults (HikariCP defaults to autoCommit=false) before feeding connections to hbm2ddl
- Prefer letting Hibernate manage its own connection provider for DDL instead of user-supplied connections
When it happens
Trigger: Running SchemaExport/SchemaUpdate against TargetType.DATABASE with a ServiceRegistry whose ConnectionProvider hands out an external connection (JdbcConnectionAccessProvidedConnectionImpl), while that connection has the opposite auto-commit mode - typically a pooled DataSource connection with autoCommit=false (HikariCP default) when the tool needs autocommit=true, or a driver/pool that ignores setAutoCommit.
Common situations: Passing a transaction-ready pooled connection into schema export during integration tests; app-managed transactions with autocommit off; deliberately setting autocommit(false) for atomic DDL and then handing the same connection to Hibernate's schema tool.
Related errors
- Error accessing user-provided Connection via JdbcConnectionA
- JDBC begin transaction failed:
- Connection [%s] passed back to %s was not the one obtained [
- Could not set provided connection [%s] to auto-commit mode (
- JDBC driver does not support named parameters for setArray.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/1f07843f9956c8e5.
Report an issue: GitHub.