Bug 1036024 - JBPM doesn't create tables automatically for "org.jbpm.persistence.jpa" persistence unit
Summary: JBPM doesn't create tables automatically for "org.jbpm.persistence.jpa" persi...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss BPMS Platform 6
Classification: Retired
Component: jBPM Core
Version: 6.0.0
Hardware: Unspecified
OS: Unspecified
high
medium
Target Milestone: ER 7
: 6.0.0
Assignee: Ryan Zhang
QA Contact: Ivo Bek
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-11-29 08:34 UTC by Ivo Bek
Modified: 2014-08-06 20:10 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-08-06 20:10:46 UTC
Type: Bug


Attachments (Terms of Use)

Description Ivo Bek 2013-11-29 08:34:08 UTC
Description of problem:

When I want to use "org.jbpm.persistence.jpa" persistence unit (PU) from persistence.xml in jbpm-test module, I receive "HibernateException: Missing table: Attachment". That's because PU doesn't specify hibernate.hbm2ddl.auto and neither it's specified in JbpmJUnitBaseTestCase. Sure I can use my own PU but the default PU is then pointless there.

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1. Start a test (can be empty) inheriting from JbpmJUnitBaseTestCase
2. The test should call super constructor super(boolean setupDataSource = true, boolean sessionPersistence = true)
3. During the call of method JbpmJUnitBaseTestCase.setUp(), see the exception about the missing table

Actual results:


Expected results:


Additional info:

Comment 1 Marek Baluch 2013-11-29 09:00:04 UTC
Lowering severity as this is in the test module and there's an easy workaround.

Comment 2 Ivo Bek 2013-11-29 12:33:01 UTC
Well the hibernate.hbm2ddl.auto property is set but to "validate" which won't create the tables. So it might be enough to change it to "create-drop" or make it possible to set it in JbpmJUnitBaseTestCase.

Comment 3 Kris Verlaenen 2013-11-29 13:38:21 UTC
Ivo, this doesn't seem to be the case in jbpm 6.0.x branch in the community:
https://github.com/droolsjbpm/jbpm/blob/6.0.x/jbpm-test/src/main/resources/META-INF/persistence.xml#L57

Do you know why there is a difference, and if so, why we shouldn't revert it?

Comment 6 Ivo Bek 2013-12-12 10:35:14 UTC
Hi Ryan,

thank you for the explanation, I don't understand much but it's important to know it's not made by an accident.

Then I suggest to change JbpmJUnitBaseTestCase a little. On the line https://github.com/droolsjbpm/jbpm/blob/master/jbpm-test/src/main/java/org/jbpm/test/JbpmJUnitBaseTestCase.java#L184 where you create the EntityManagerFactory (emf = Persistence.createEntityManagerFactory(persistenceUnitName);), I would add a map as the optional parameter, containing the hibernate.hbm2ddl.auto property to override the "validate" value with "update", so only if JbpmJUnitBaseTestCase were used with persistence, the tables would be created.

Comment 7 Kris Verlaenen 2013-12-12 21:27:19 UTC
Ryan, the persistence.xml is in the jbpm-test module, it should only be included for JUnit tests (where you can easily instantiate a test environment, using H2 and bitronix).

It seems unlikely FSW needs this jar (if they are using it, it might be worth checking why, because I believe it should probably be excluded).  So I would recommend to change the hibernate.hbm2dll.auto property back to update, as I believe this should not impact FSW.

FSW should define their own persistence.xml (similar to how our workbench for example defines one - https://github.com/droolsjbpm/kie-wb-distributions/blob/master/kie-wb/kie-wb-webapp/src/main/resources/META-INF/persistence.xml), and there they can set their own properties.

Comment 8 Kris Verlaenen 2013-12-12 21:28:32 UTC
Setting as blocker as this needs to be resolved, otherwise the jbpm-test jar will be useless.

Comment 9 Ryan Zhang 2013-12-13 07:19:35 UTC
Ok, Kris, I can recover the proprety to update now.

FSW don't need this jar. The reason it patched the jbpm-test.jar is to make hibernateMavenPlugin working which is design to generate DB schemal from persistence.xml. If I understand correctly, the plugin will scan all persistence.xml in jbpm and generating the db schema. 
I would discuss with my colleage  about if FSW should use their own persistence.xml or not. But for now, because decision has been made that FSW will freeze on droolsjbpm version (ER5), until GA. So we can fix this issue as you suggested without any impact to FSW. 



(In reply to Kris Verlaenen from comment #7)
> Ryan, the persistence.xml is in the jbpm-test module, it should only be
> included for JUnit tests (where you can easily instantiate a test
> environment, using H2 and bitronix).
> 
> It seems unlikely FSW needs this jar (if they are using it, it might be
> worth checking why, because I believe it should probably be excluded).  So I
> would recommend to change the hibernate.hbm2dll.auto property back to
> update, as I believe this should not impact FSW.
> 
> FSW should define their own persistence.xml (similar to how our workbench
> for example defines one -
> https://github.com/droolsjbpm/kie-wb-distributions/blob/master/kie-wb/kie-wb-
> webapp/src/main/resources/META-INF/persistence.xml), and there they can set
> their own properties.

Comment 10 Ivo Bek 2014-01-06 13:28:22 UTC
Verified in BPMS 6.0.0.ER7


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