Bug 841786 - SessionInfo table doesn't get the MySQL AUTO_INCREMENT flag on EAP6
SessionInfo table doesn't get the MySQL AUTO_INCREMENT flag on EAP6
Product: JBoss Enterprise BRMS Platform 5
Classification: JBoss
Component: BRE (Expert, Fusion) (Show other bugs)
BRMS 5.3.0.GA
Unspecified Unspecified
unspecified Severity high
: ---
: ---
Assigned To: Shelly McGowan
Radovan Synek
Depends On:
  Show dependency treegraph
Reported: 2012-07-20 04:59 EDT by Lukáš Petrovický
Modified: 2016-09-20 01:08 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
AS Config (the relevant DS is java:/jBPMDS (17.96 KB, text/xml)
2012-07-20 04:59 EDT, Lukáš Petrovický
no flags Details
persistence.xml (1.65 KB, text/xml)
2012-07-20 05:00 EDT, Lukáš Petrovický
no flags Details
persistence.xml for H2DB (1.69 KB, text/xml)
2012-08-28 07:21 EDT, Tomas Schlosser
no flags Details

  None (edit)
Description Lukáš Petrovický 2012-07-20 04:59:19 EDT
Created attachment 599337 [details]
AS Config (the relevant DS is java:/jBPMDS

When trying the jBPM console out with EAP6 and MySQL 5.5, I have stumbled into the following exception:

Caused by: java.sql.SQLException: Field 'id' doesn't have a default value
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3597)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3529)
	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1990)
	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2151)
	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2625)
	at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2119)
	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2415)
	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2333)
	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2318)
	at com.mysql.jdbc.jdbc2.optional.PreparedStatementWrapper.executeUpdate(PreparedStatementWrapper.java:875)
	at org.jboss.jca.adapters.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:493)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_03-icedtea]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_03-icedtea]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_03-icedtea]
	at java.lang.reflect.Method.invoke(Method.java:601) [rt.jar:1.7.0_03-icedtea]
	at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:122) [hibernate-core-4.1.3.Final-redhat-1.jar:4.1.3.Final-redhat-1]
	... 75 more

Turns out, it is caused by the SessionInfo table, which doesn't have the AUTO_INCREMENT flag set. The exact same codebase works with EAP5, suggesting this must be a difference between JPA1 and JPA2.

See attached AS config and persistence.xml.
Comment 1 Lukáš Petrovický 2012-07-20 05:00:13 EDT
Created attachment 599338 [details]

The persistence.xml exhibiting the issue.
Comment 2 Tomas Schlosser 2012-08-28 07:21:16 EDT
Created attachment 607479 [details]
persistence.xml for H2DB

The same exception occurs if you use default EAP6 database. I include persistence.xml from business-central.war that is set up to use JPA2 classes. The exact exception is:

Caused by: org.h2.jdbc.JdbcSQLException: NULL not allowed for column "ID"; SQL statement:
     insert into SessionInfo (id, lastModificationDate, rulesByteArray, startDate, OPTLOCK) values (null, ?, ?, ?, ?)
Comment 3 Jiri Svitak 2012-08-29 11:39:53 EDT
The same exception happens with MS SQL Server 2008 when using Hibernate 4 on EAP 6.0:

Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Cannot insert the value NULL into column 'id', table 'dballo01.dbo.SessionInfo'; column does not allow nulls. INSERT fails.
Comment 4 Marco Rietveld 2012-08-30 15:22:59 EDT
Figured this out, it's basically this, I think: 
- https://hibernate.onjira.com/browse/HHH-6648

The work-around/fix is to add the following line to your persistence.xml:

<property name="hibernate.id.new_generator_mappings" value="false" />

We're making EAP 6 specific wars (console-server, human-task) and the persistence.xml files used in both will include the following: 

      <!-- BZ 841786: AS7/EAP 6/Hib 4 uses new (sequence) generators which seem to cause problems -->      
      <property name="hibernate.id.new_generator_mappings" value="false" />
Comment 5 Marco Rietveld 2012-08-31 07:37:53 EDT
The jbpm-distribution module now creates gwt-console-server and jbpm-human-task wars for EAP6 (classifier: EE6). 

Both of these now contain persistence.xml files with the lines mentioned above.
Comment 6 Radovan Synek 2012-09-21 06:12:28 EDT
Verifier on 5.3.1.BRMS-ER1 (works with brms-p-5.3.1.ER1-deployable-ee6).
Comment 7 lcarlon 2012-11-05 20:36:14 EST
Marked as not needing release notes as deploying to EAP6 isn't supported until 5.3.1

Note You need to log in before you can comment on or make changes to this bug.