Uploaded image for project: 'JBoss BPMS Platform'
  1. JBoss BPMS Platform
  2. RHBPMS-5107

[GSS] (6.4.z) Redundant records are inserted by JPAPlaceholderResolverStrategy

    Details

    • Target Release:
    • Fix Build:
      CR1
    • Steps to Reproduce:
      • Unzip 02008390_reproducer04.zip
      • mvn test

      Description

      When you have an entity with a relationship (ManyToOne, but reproducible with OneToOne) to a child entity and persist it as a process variable using JPAPlaceholderResolverStrategy, its child entity is inserted multiple times so it results in multiple redundant records in DB.

      Attached a reproducer 02008390_reproducer04.zip. You can run it with "mvn test".

      Running com.sample.ProcessJPATest
      ...
      Task1 Entry
      A process instance started : pid = 1
      john starts a task : taskId = 1
      Task1 Exit
      Task2 Entry
      mary starts a task : taskId = 2
      Task2 Exit
      java.lang.AssertionError: expected:<1> but was:<8>
      	at org.junit.Assert.fail(Assert.java:88)
      	at org.junit.Assert.failNotEquals(Assert.java:834)
      	at org.junit.Assert.assertEquals(Assert.java:645)
      	at org.junit.Assert.assertEquals(Assert.java:631)
      	at com.sample.ProcessJPATest.testProcess(ProcessJPATest.java:135)
      ...
      

      The reproducer runs with H2 but if I change it to MySQL and check the database, the result is like this.

      mysql> select * from application;
      +----+------+-----------+
      | id | type | person_id |
      +----+------+-----------+
      |  1 | A    |         8 |
      +----+------+-----------+
      1 row in set (0.00 sec)
      
      mysql> select * from person;
      +----+----------+
      | id | fullName |
      +----+----------+
      |  1 | John Doe |
      |  2 | John Doe |
      |  3 | John Doe |
      |  4 | John Doe |
      |  5 | John Doe |
      |  6 | John Doe |
      |  7 | John Doe |
      |  8 | John Doe |
      +----+----------+
      8 rows in set (0.00 sec)
      

      Using a debugger, I observed the Person (child entity) insertion happens every time JPAPlaceholderResolverStrategy.marshal() calls em.merge() for Application (parent entity) during the transaction on Task completion.

      https://github.com/kiegroup/drools/blob/6.5.x/drools-persistence-jpa/src/main/java/org/drools/persistence/jpa/marshaller/JPAPlaceholderResolverStrategy.java#L118
      https://github.com/kiegroup/drools/blob/6.5.x/drools-persistence-jpa/src/main/java/org/drools/persistence/jpa/marshaller/JPAPlaceholderResolverStrategy.java#L121

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  swiderski.maciej Maciej Swiderski
                  Reporter:
                  tkobayashi Toshiya Kobayashi
                  Tester:
                  Marian Macik
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: