Issue Type: Bug Bug
Affects Versions: 4.1.11
Assignee: Unassigned
Components: metamodel
Created: 03/Jul/13 2:52 PM
Description:

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.

Environment: PostgreSQL
Project: Hibernate ORM
Priority: Major Major
Reporter: Sébastien Deleuze
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira