{"record":{"id":"d75575d3c89b13d0","repo":"hibernate/hibernate-orm","slug":"could-not-fetch-the-sequenceinformation-from-the-d","errorCode":null,"errorMessage":"Could not fetch the SequenceInformation from the database","messagePattern":"Could not fetch the SequenceInformation from the database","errorType":"exception","errorClass":"HibernateException","httpStatus":null,"severity":"critical","filePath":"hibernate-core/src/main/java/org/hibernate/engine/jdbc/env/internal/ExtractedDatabaseMetaDataImpl.java","lineNumber":266,"sourceCode":"\t\tcatch (SQLException ignore) {\n\t\t\treturn  -1;\n\t\t}\n\t}\n\n\t/**\n\t * Get the sequence information List from the database.\n\t *\n\t * @return sequence information List\n\t */\n\tprivate List<SequenceInformation> sequenceInformationList() {\n\t\tConnection connection = null;\n\t\ttry {\n\t\t\tconnection = connectionAccess.obtainConnection();\n\t\t\treturn stream( sequenceInformation( connection, jdbcEnvironment ).spliterator(), false )\n\t\t\t\t\t.toList();\n\t\t}\n\t\tcatch (SQLException e) {\n\t\t\tthrow new HibernateException( \"Could not fetch the SequenceInformation from the database\", e );\n\t\t}\n\t\tfinally {\n\t\t\tif ( connection != null ) {\n\t\t\t\ttry {\n\t\t\t\t\tconnectionAccess.releaseConnection( connection );\n\t\t\t\t}\n\t\t\t\tcatch (SQLException exception) {\n\t\t\t\t\tJDBC_LOGGER.unableToReleaseConnection( exception );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static Iterable<SequenceInformation> sequenceInformation(Connection connection, JdbcEnvironment jdbcEnvironment)\n\t\t\tthrows SQLException {\n\t\treturn jdbcEnvironment.getDialect().getSequenceInformationExtractor().extractMetadata(\n\t\t\t\tnew ExtractionContext.EmptyExtractionContext() {\n\t\t\t\t\t@Override","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/engine/jdbc/env/internal/ExtractedDatabaseMetaDataImpl.java#L248-L284","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// smoke-test sequence metadata access before building the factory\ntry (Connection c = dataSource.getConnection();\n     ResultSet rs = c.getMetaData().getTables(null, null, \"SEQUENCES\", null)) {\n    if (!rs.next() && isOracleLike(url)) {\n        throw new IllegalStateException(\"no access to sequence metadata views\");\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    sessionFactory = new Configuration().configure().buildSessionFactory();\n}\ncatch (HibernateException e) {\n    // cause chain contains the SQLException from the sequence query\n    Throwable root = getRootCause(e);\n    throw new StartupFailure(\"sequence metadata extraction failed: \" + root, e);\n}","preventionTips":["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"],"tags":["boot","sequence","metadata","id-generation","database","hibernate"],"backgroundTag":"database-metadata-extraction-failed","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}