Hi. We're using Hibernate 4.0.0 in JBoss 7.1.0.CR1b with Derby 10.8 and encountering a problem apparently caused by a missing HIBERNATE_SEQUENCE:
Code:
18:14:19,535 ERROR [org.jboss.ejb3.invocation] (MSC service thread 1-4) JBAS014134: EJB Invocation failed on component MyEJBfor method public abstract void com.example.MyEJB.checkDBVersion(): javax.ejb.EJBException: java.lang.IllegalStateException: JBAS011048: Failed to construct component instance
Caused by: java.lang.IllegalStateException: JBAS011048: Failed to construct component instance
Caused by: javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: SEQUENCE 'HIBERNATE_SEQUENCE' does not exist.
Caused by: org.hibernate.exception.SQLGrammarException: SEQUENCE 'HIBERNATE_SEQUENCE' does not exist.
Caused by: java.sql.SQLSyntaxErrorException: SEQUENCE 'HIBERNATE_SEQUENCE' does not exist.
Caused by: org.apache.derby.client.am.SqlException: SEQUENCE 'HIBERNATE_SEQUENCE' does not exist.
(two pages of stack traces snipped)
If I set the property 'hibernate.hbm2ddl.auto' to 'update' then the error doesn't occur (the log shows HIBERNATE_SEQUENCE being created, as we might expect), but in normal usage we prefer not to set this property. Instead we're using org.hibernate.tool.hbm2ddl.SchemaExport to generate the database schema & using this to create the database before deploying our app to JBoss.
The schema generated by SchemaExport for the DerbyTenSevenDialect doesn't create HIBERNATE_SEQUENCE, which is presumably the cause of this issue. However, I note when we create the schema using the PostgreSQLDialect in the same way, a "create sequence hibernate_sequence;" line is included in the exported schema, and thus the "HIBERNATE_SEQUENCE does not exist" error doesn't occur when we're using a Postgres datasource.
We're not sure what to make of this.
Are we correct to expect the schema output by SchemaExport to create hibernate_sequence if hibernate_sequence will be required to access the exported database through Hibernate/JPA using the same dialect?
Is there something specific we should do to force SchemaExport to include the hibernate_sequence for the DerbyTenSevenDialect?