Out of Date
Details
Assignee
UnassignedUnassignedReporter
Sébastien DeleuzeSébastien DeleuzeComponents
Affects versions
Priority
Major
Details
Details
Assignee
Unassigned
UnassignedReporter
Sébastien Deleuze
Sébastien DeleuzeComponents
Affects versions
Priority
Created July 3, 2013 at 9:52 PM
Updated July 19, 2015 at 4:13 PM
Resolved July 19, 2015 at 4:13 PM
The issue occur in the last lines of org.hibernate.cfg.Configuration.generateSchemaUpdateScript() where the isSequence method return bogus values.
https://github.com/hibernate/hibernate-orm/blob/master/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java#L1270
In DatabaseMetadata, sequences HashSet still use unqualified sequence name, so isSequence() method does not take in account sequence schema or catalog. For information, isTable() implementation is fine are manage takes in account schemas and catalogs.
https://github.com/hibernate/hibernate-orm/blob/master/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/DatabaseMetadata.java#L193
I think DatabaseMetadata.initSequence should use identifier(catalog, schema, name) instead of just sequence name to populate the sequences Hashset, and DatabaseMetadata.isSequence logic updated accordingly.
https://github.com/hibernate/hibernate-orm/blob/master/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/DatabaseMetadata.java#L166
Test case : if you have 2 applications application1 and application2 using each their own schema (quite common) : schema1 and schema2. They are configured with hibernate.hbm2ddl.auto=update
You start application1 with an empty database, it will work as expected, tables and sequence are created in schema1. But when you start application2, tables will be created in schema2 but not the sequence because schema1.hibernate_sequence will be processed as hibernate_sequence, so schema2.hibernate_sequence will never be created.