hibernate/hibernate-orm · critical · HibernateException
Could not fetch the SequenceInformation from the database
Error message
Could not fetch the SequenceInformation from the database
What it means
During SessionFactory bootstrap, ExtractedDatabaseMetaDataImpl.sequenceInformationList() opens a connection and queries the database for sequence metadata (used to validate and align sequence-based identifier generators, e.g. allocationSize/increment mismatches). Any SQLException while obtaining the connection or executing the extraction query is wrapped in this HibernateException, which fails boot.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/engine/jdbc/env/internal/ExtractedDatabaseMetaDataImpl.java:266
catch (SQLException ignore) {
return -1;
}
}
/**
* Get the sequence information List from the database.
*
* @return sequence information List
*/
private List<SequenceInformation> sequenceInformationList() {
Connection connection = null;
try {
connection = connectionAccess.obtainConnection();
return stream( sequenceInformation( connection, jdbcEnvironment ).spliterator(), false )
.toList();
}
catch (SQLException e) {
throw new HibernateException( "Could not fetch the SequenceInformation from the database", e );
}
finally {
if ( connection != null ) {
try {
connectionAccess.releaseConnection( connection );
}
catch (SQLException exception) {
JDBC_LOGGER.unableToReleaseConnection( exception );
}
}
}
}
private static Iterable<SequenceInformation> sequenceInformation(Connection connection, JdbcEnvironment jdbcEnvironment)
throws SQLException {
return jdbcEnvironment.getDialect().getSequenceInformationExtractor().extractMetadata(
new ExtractionContext.EmptyExtractionContext() {
@OverrideView on GitHub (pinned to fad1729dce)
Solutions
- Run the same connection URL/user manually and the dialect's sequence query (e.g. select from ALL_SEQUENCES / information_schema.sequences) to see the real error
- Grant the DB account SELECT access to the sequence metadata views/tables the dialect reads
- Verify the dialect matches your database version; upgrade Hibernate so the SequenceInformationExtractor fits the DB (notably H2 2.x)
- As a workaround for locked-down environments, configure identifier strategies that do not require sequence validation (e.g. UUID or pooled optimizers with correct allocationSize matching the DB sequence)
Defensive patterns
Strategy: validation
Validate before calling
// smoke-test sequence metadata access before building the factory
try (Connection c = dataSource.getConnection();
ResultSet rs = c.getMetaData().getTables(null, null, "SEQUENCES", null)) {
if (!rs.next() && isOracleLike(url)) {
throw new IllegalStateException("no access to sequence metadata views");
}
} Try / catch
try {
sessionFactory = new Configuration().configure().buildSessionFactory();
}
catch (HibernateException e) {
// cause chain contains the SQLException from the sequence query
Throwable root = getRootCause(e);
throw new StartupFailure("sequence metadata extraction failed: " + root, e);
} Prevention
- Grant metadata-view read access to the Hibernate DB user
- Pin the dialect that matches your exact database version
- Include a boot smoke test in CI so privilege regressions surface before deploy
When it happens
Trigger: Booting with @GeneratedValue(strategy = SEQUENCE) (or default allocationSize 50) against a database where the sequence-metadata query fails: the DB user cannot read the sequence catalog (e.g. ALL_SEQUENCES, information_schema.sequences), the dialect's SequenceInformationExtractor does not match the actual DB version, or the connection drops during boot.
Common situations: Locked-down DB accounts without metadata-view grants; H2 1.x to 2.x upgrades that changed catalog tables; using an Oracle/MariaDB/SQL Server dialect version that does not match the server; transient network failures at deploy time.
Related errors
- dialect does not support sequences
- SQM INSERT-SELECT without bulk insertion capable identifier
- Error performing isolated work
- Schema validation: missing sequence [%s]
- Schema validation: sequence [%s] defined inconsistent increm
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/d75575d3c89b13d0.
Report an issue: GitHub.