Hello,
we have just upgraded from WildFly 9 to 10 and therefore also upgraded from Hibernate 4 to 5.
Our application uses entities that are derived from a abstract super entity that has a generated id field.
The super class looks like this:
Code:
@MappedSuperclass
@Access(AccessType.FIELD)
@SqlResultSetMapping(name = EntityId.rsmId,
columns = { @ColumnResult(name = "id", type = Long.class) })
public abstract class EntityId
{
@GeneratedValue(strategy = GenerationType.TABLE, generator = "generator1")
@TableGenerator(name = "generator1",
pkColumnValue = "g1",
initialValue = 0, allocationSize = 1000,
schema = "schema2", table = "sysidgenerator", // MySQL
pkColumnName = "gen_key", valueColumnName = "gen_val")
@Column(name = "id")
@Id
private Long id;
[...]
}
and our datasource is configured like this:
Code:
<xa-datasource jndi-name="java:jboss/datasources/MTDS" pool-name="MTDS" enabled="true" use-ccm="false">
<xa-datasource-property name="URL">
jdbc:mysql://server:3306/schema
</xa-datasource-property>
<driver>com.mysql</driver>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
<xa-pool>
<min-pool-size>3</min-pool-size>
<max-pool-size>40</max-pool-size>
<is-same-rm-override>false</is-same-rm-override>
<interleaving>false</interleaving>
<pad-xid>false</pad-xid>
<wrap-xa-resource>false</wrap-xa-resource>
</xa-pool>
<security>
<user-name>user</user-name>
<password>password</password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/>
<validate-on-match>false</validate-on-match>
<background-validation>true</background-validation>
<background-validation-millis>15000</background-validation-millis>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter"/>
</validation>
<statement>
<prepared-statement-cache-size>0</prepared-statement-cache-size>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</xa-datasource>
With Hibernate 4 everything worked perfect. After the upgrade we get the following error:
Code:
ERROR [x.y.z] (default task-13) Caught exception.: javax.ejb.EJBTransactionRolledbackException: org.hibernate.HibernateException: Could not apply work
Caused by: org.hibernate.HibernateException: Unable to perform isolated work
at org.hibernate.resource.transaction.backend.jta.internal.JtaIsolationDelegate.doTheWork(JtaIsolationDelegate.java:139)
at org.hibernate.resource.transaction.backend.jta.internal.JtaIsolationDelegate.doTheWorkInNewTransaction(JtaIsolationDelegate.java:100)
... 253 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'schema.sysidgenerator' doesn't exist
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
at com.mysql.jdbc.Util.getInstance(Util.java:384)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4232)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4164)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2615)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2776)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2838)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2082)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2212)
at com.mysql.jdbc.jdbc2.optional.PreparedStatementWrapper.executeQuery(PreparedStatementWrapper.java:844)
at org.jboss.jca.adapters.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:504)
at org.hibernate.id.enhanced.TableGenerator.executeQuery(TableGenerator.java:639)
at org.hibernate.id.enhanced.TableGenerator.access$400(TableGenerator.java:127)
at org.hibernate.id.enhanced.TableGenerator$1$1.execute(TableGenerator.java:541)
at org.hibernate.id.enhanced.TableGenerator$1$1.execute(TableGenerator.java:531)
at org.hibernate.jdbc.WorkExecutor.executeReturningWork(WorkExecutor.java:55)
at org.hibernate.jdbc.AbstractReturningWork.accept(AbstractReturningWork.java:34)
at org.hibernate.resource.transaction.backend.jta.internal.JtaIsolationDelegate.doTheWork(JtaIsolationDelegate.java:133)
... 254 more
For some reason Hibernate is now looking for the table 'schema.sysidgenerator' and not for 'schema2.sysidgenerator' like it is configured in the @TableGenerator.
What do we have to do to fix this?
Suggestions appreciated.
Regards
Eustachius