7 Replies Latest reply on Apr 9, 2007 10:00 AM by kukeltje

    strange problem with many-to-one mapping in jbpm 3.2

    camunda

      Hi!

      I have a very strange problem with the current jbpm 3.2. When I deploy a process a lot of columns which schould be filled are set to NULL in the database. Inspecting further I found, that ALL many-to-one mappings are set to NULL in the database, even if the association (the "Java-Pointer") was set correctly!

      As a example take the start-state of a process-definition.

      I started debugging in Hibernate (3.2.3 by the way) and found the following:

      Hibernate males a check to set all transient attributes to null (makes sense):

      new ForeignKeys.Nullifier( entity, false, useIdentityColumn, source ).nullifyTransientReferences( values, types ); (AbstractSaveEventListener, 288)
      

      If it checks the StartState, it finds the primary key ID=0, which leads hibernate to the assumption, this SuperSate is a transient object. So it is set to NULL!
      This is a very strange behavior, because I think Hibernate should generate that key on its own!

      I have no idea, why that happens in this new version of jbpm. Because I looked at the hibernate-mappings, and they haven't changed too much since 3.1.

      By the way, I use mySQL 5...

      ANY ideas to that issue? It took me already a lot of time to come to the point that I have no idea :-(

      Thanks for every hint!!

      Regards

      Bernd

        • 1. Re: strange problem with many-to-one mapping in jbpm 3.2
          camunda

          I played arount with the ID Generator setting, but nothing changed :-(

          • 2. Re: strange problem with many-to-one mapping in jbpm 3.2
            brittm

            I don't have an answer, but simply for comparison, I don't seem to be having those kinds of issues with 3.2.GA.

            I'm running on Oracle against an existing 3.1.2 database on which I ran the (slightly modified) update scripts.

            -Britt

            • 3. Re: strange problem with many-to-one mapping in jbpm 3.2
              camunda

              Hi Britt,

              I also have a updates 3.1.2 databases updated. But that seems not to be the problem. The problem is really I think the ID generation. But I don't understand why....

              • 4. Re: strange problem with many-to-one mapping in jbpm 3.2
                camunda

                Okay, I have investigated further.

                I use the DeployProcessCommand (committed to CVS HEAD one minute ago). If I call that from a test case in the jbpm project (which goes directly to the database), everything is working fine. Even if I switch to mySQL for the test-cases, no problem.

                No I execute exactly the same command (with exactly the same process) inside a EJB 3.0 SessionBean, where the JbpmContext is injected from the JBoss AS (with mySQL as a local-tx-datasource), then I have a lot of NULL values in my many-to-one mappings.

                Maybe it has something to do with the JTA environment. But I don't know why. And where is the difference to jbpm 3.1?

                • 5. Re: strange problem with many-to-one mapping in jbpm 3.2
                  camunda

                  Okay, one day later and one small step further, I compared the logs of the JTA-run:

                  [org.jbpm.configuration.JbpmContextInfo] creating jbpm context with service factories '[tx, message, scheduler, logging, persistence, authentication]'
                  [org.jbpm.JbpmContext] creating org.jbpm.JbpmContext@1a890f
                  [com.camunda.toolkit.jbpm.service.CommandServiceBean] executing org.jbpm.command.DeployProcessCommand@1c3dfe...
                  [org.jbpm.command.DeployProcessCommand] parse process from String
                  [org.jbpm.command.DeployProcessCommand] deploy process: <process-definition name='Test2'><start-state name='start'></start-state></process-definition>
                  [org.jbpm.graph.node.NodeTypes] node 'page' will not be available. class 'org.jboss.seam.pageflow.Page' couldn't be loaded
                  [org.jbpm.graph.node.NodeTypes] node 'start-page' will not be available. class 'org.jboss.seam.pageflow.Page' couldn't be loaded
                  [org.jbpm.persistence.db.DbPersistenceServiceFactory] creating persistence service
                  [org.jbpm.persistence.db.DbPersistenceService] creating hibernate session
                  [org.jbpm.persistence.db.DbPersistenceService] beginning hibernate transaction
                  [STDOUT] Hibernate: select processdef0_.ID_ as ID1_50_, processdef0_.NAME_ as NAME3_50_, processdef0_.DESCRIPTION_ as DESCRIPT4_50_, processdef0_.VERSION_ as VERSION5_50_, processdef0_.ISTERMINATIONIMPLICIT_ as ISTERMIN6_50_, processdef0_.STARTSTATE_ as STARTSTATE7_50_ from JBPM_PROCESSDEFINITION processdef0_ where processdef0_.NAME_=? order by processdef0_.VERSION_ desc limit ?
                  [STDOUT] Hibernate: insert into JBPM_PROCESSDEFINITION (NAME_, DESCRIPTION_, VERSION_, ISTERMINATIONIMPLICIT_, STARTSTATE_, CLASS_) values (?, ?, ?, ?, ?, 'P')
                  [STDOUT] Hibernate: insert into JBPM_NODE (NAME_, DESCRIPTION_, PROCESSDEFINITION_, ISASYNC_, ISASYNCEXCL_, ACTION_, SUPERSTATE_, CLASS_) values (?, ?, ?, ?, ?, ?, ?, 'R')
                  [STDOUT] Hibernate: insert into JBPM_MODULEDEFINITION (NAME_, PROCESSDEFINITION_, CLASS_) values (?, ?, 'C')
                  [STDOUT] Hibernate: insert into JBPM_MODULEDEFINITION (NAME_, PROCESSDEFINITION_, STARTTASK_, CLASS_) values (?, ?, ?, 'T')
                  [org.jbpm.command.DeployProcessCommand] deployment sucessfull
                  [com.camunda.toolkit.jbpm.service.CommandServiceBean] ... finished with org.jbpm.command.DeployProcessCommand@1c3dfe
                  [org.jbpm.JbpmContext] closing JbpmContext
                  [org.jbpm.svc.Services] closing service 'persistence': org.jbpm.persistence.db.DbPersistenceService@186b2ca
                  [org.jbpm.persistence.db.DbPersistenceService] committing hibernate transaction
                  [org.jbpm.persistence.db.DbPersistenceService] closing hibernate session
                  [org.jbpm.svc.Services] closing service 'tx': org.jbpm.tx.TxService@43f7d7
                  [org.jbpm.svc.Services] closing service 'authentication': org.jbpm.security.authentication.DefaultAuthenticationService@444a8b
                  


                  and the local Testrun:

                  [main] DEBUG DbPersistenceService : creating hibernate session
                  [main] DEBUG DbPersistenceService : beginning hibernate transaction
                  [main] DEBUG AbstractDbTestCase :
                  [main] DEBUG AbstractDbTestCase : ### starting testProcessDefinitionStartState ####################################################
                  [main] INFO DeployProcessCommand : parse process from String
                  [main] DEBUG DeployProcessCommand : deploy process: <process-definition name='Test2'><start-state name='start'></start-state></process-definition>
                  [main] DEBUG NodeTypes : node 'page' will not be available. class 'org.jboss.seam.pageflow.Page' couldn't be loaded
                  [main] DEBUG NodeTypes : node 'start-page' will not be available. class 'org.jboss.seam.pageflow.Page' couldn't be loaded
                  Hibernate: select processdef0_.ID_ as ID1_0_, processdef0_.NAME_ as NAME3_0_, processdef0_.DESCRIPTION_ as DESCRIPT4_0_, processdef0_.VERSION_ as VERSION5_0_, processdef0_.ISTERMINATIONIMPLICIT_ as ISTERMIN6_0_, processdef0_.STARTSTATE_ as STARTSTATE7_0_ from JBPM_PROCESSDEFINITION processdef0_ where processdef0_.NAME_=? order by processdef0_.VERSION_ desc limit ?
                  Hibernate: insert into JBPM_PROCESSDEFINITION (NAME_, DESCRIPTION_, VERSION_, ISTERMINATIONIMPLICIT_, STARTSTATE_, CLASS_) values (?, ?, ?, ?, ?, 'P')
                  Hibernate: insert into JBPM_NODE (NAME_, DESCRIPTION_, PROCESSDEFINITION_, ISASYNC_, ISASYNCEXCL_, ACTION_, SUPERSTATE_, CLASS_) values (?, ?, ?, ?, ?, ?, ?, 'R')
                  Hibernate: insert into JBPM_MODULEDEFINITION (NAME_, PROCESSDEFINITION_, CLASS_) values (?, ?, 'C')
                  Hibernate: insert into JBPM_MODULEDEFINITION (NAME_, PROCESSDEFINITION_, STARTTASK_, CLASS_) values (?, ?, ?, 'T')
                  [main] INFO DeployProcessCommand : deployment sucessfull
                  [main] DEBUG AbstractDbTestCase : ### testProcessDefinitionStartState done ####################################################
                  [main] DEBUG AbstractDbTestCase :
                  [main] DEBUG JbpmContext : closing JbpmContext
                  [main] DEBUG Services : closing service 'persistence': org.jbpm.persistence.db.DbPersistenceService@789869
                  [main] DEBUG DbPersistenceService : committing hibernate transaction
                  Hibernate: update JBPM_PROCESSDEFINITION set NAME_=?, DESCRIPTION_=?, VERSION_=?, ISTERMINATIONIMPLICIT_=?, STARTSTATE_=? where ID_=?
                  Hibernate: update JBPM_NODE set PROCESSDEFINITION_=?, NODECOLLECTIONINDEX_=? where ID_=?
                  Hibernate: update JBPM_MODULEDEFINITION set PROCESSDEFINITION_=?, NAME_=? where ID_=?
                  Hibernate: update JBPM_MODULEDEFINITION set PROCESSDEFINITION_=?, NAME_=? where ID_=?
                  [main] DEBUG DbPersistenceService : closing hibernate session
                  [main] DEBUG Services : closing service 'tx': org.jbpm.tx.TxService@17e4dee
                  


                  Really eye-catching is, that in the local Testrun, there are some additonal UPDATES, which are missing in the JTA version. I think, they correct the ID's, because the ID's were generated from the database during the first INSERT and so not known in advance. So we really need these second updates for the many-to-one associations.

                  But why is that missing in the JTA version? May some small implementation issue in jbpm 3.2. I will investigate further.

                  And I have created a JIRAA-Issue for that: http://jira.jboss.com/jira/browse/JBPM-944

                  • 6. Re: strange problem with many-to-one mapping in jbpm 3.2
                    camunda

                    Okay, I solved it. It was my own silly fault! Sorry for the unnecessary traffic in that forum ;-)

                    The solution is: Switch the PersistenceService in the jbpm.cfg.xml to "JtaDbPersistenceService". After changing that, it also workes fine with JTA!

                    Sorry again and happy jbpm'ing again :-)

                    • 7. Re: strange problem with many-to-one mapping in jbpm 3.2
                      kukeltje

                      I don't mind this kind of traffic. People solving their own problems and reporting the sollution. Others can learn from this... :-)