OpenJPA
  1. OpenJPA
  2. OPENJPA-1550

When batchLimit=-1 or >1 and an exception is caused, the params and failedObject are missing from the resultant exception.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.2.2, 1.3.0, 2.0.0-beta2
    • Fix Version/s: 1.2.3, 1.3.0, 2.0.0, 2.1.0
    • Component/s: jdbc
    • Labels:
      None
    • Patch Info:
      Patch Available

      Description

      Exception reporting is different depending on the value of batchLimit. To describe and demonstration this problem, lets take the following Entitiy:

      @Entity
      public class Ent1

      { @Id private int pk; private String name; ..... }

      As a test, lets assume that we have an Ent1 with pk=200 already defined in the DB and our test will attempt to create and persist another Ent1 with pk=200 (i.e. a duplicate key). In so doing we get the following exception as indicated by the batchLimit settings:

      batchLimit=0 or batchLimit=1
      Caused by: <openjpa-1.2.2-SNAPSHOT-r422266:889769M nonfatal store error> org.apache.openjpa.persistence.EntityExistsException: The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint or unique index identified by 'SQL100301111328870' defined on 'ENT1'.

      {prepstmnt 33038075 INSERT INTO Ent1 (pk, name) VALUES (?, ?) [params=(int) 200, (String) twohundred]}

      [code=20000, state=23505]
      FailedObject: siemens75007.Ent1@19d0e0b

      when batchLimit=-1 or >1
      Caused by: <openjpa-1.2.2-SNAPSHOT-r422266:889769M nonfatal store error> org.apache.openjpa.persistence.EntityExistsException: The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint or unique index identified by 'SQL100301111328870' defined on 'ENT1'.
      FailedObject: prepstmnt 33038075 INSERT INTO Ent1 (pk, name) VALUES (?, ?) [org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement]

      Notice that when batchLimit=[0,1], the exception lists the prepared statement used along with the params which caused the failure, as well as the 'FailedObject'. Furthermore, calling 'getFailedObject' on the resultant exception will give the caller the entity which caused the failure. In contrast, when batchLimit=-1 or a value greater than 1, we can see that the exception message is missing the prepared statement info, however, it is presented in the 'FailedObject'. The params are also missing from the prepared statement. A call to 'getFailedObject' on the resultant exception will NOT give the caller the entity which caused the exception.

      1. OPENJPA-1550-trunk-testcase.patch.txt
        29 kB
        Heath Thomann
      2. OPENJPA-1550-13x-v2.diff.txt
        4 kB
        Heath Thomann
      3. OPENJPA-1550v2.diff.txt
        4 kB
        Heath Thomann
      4. OPENJPA-1550-13x-testcase.patch.txt
        27 kB
        Heath Thomann
      5. OPENJPA-1550.diff.txt
        29 kB
        Heath Thomann
      6. OPENJPA-1550-trunk.patch
        13 kB
        Donald Woods
      7. OPENJPA-1550-13x.patch
        13 kB
        Donald Woods

        Activity

        Heath Thomann created issue -
        Hide
        Heath Thomann added a comment -

        Proposed code changes for this issue.

        Show
        Heath Thomann added a comment - Proposed code changes for this issue.
        Heath Thomann made changes -
        Field Original Value New Value
        Attachment OPENJPA-1550.diff.txt [ 12437968 ]
        Donald Woods made changes -
        Fix Version/s 1.2.3 [ 12314517 ]
        Fix Version/s 1.3.0 [ 12313326 ]
        Fix Version/s 2.0.0 [ 12314019 ]
        Affects Version/s 2.0.0-beta2 [ 12314802 ]
        Affects Version/s 1.3.0 [ 12313326 ]
        Donald Woods made changes -
        Assignee Heath Thomann [ jpaheath ] Donald Woods [ drwoods ]
        Hide
        Donald Woods added a comment -

        Updated patch for 1.3.x branch

        Show
        Donald Woods added a comment - Updated patch for 1.3.x branch
        Donald Woods made changes -
        Attachment OPENJPA-1550-13x.patch [ 12438323 ]
        Hide
        Donald Woods added a comment -

        updated patch that can be applied to trunk. waiting for all junits and TCKs to finish before committing.

        Show
        Donald Woods added a comment - updated patch that can be applied to trunk. waiting for all junits and TCKs to finish before committing.
        Donald Woods made changes -
        Attachment OPENJPA-1550-trunk.patch [ 12438328 ]
        Hide
        Donald Woods added a comment -

        Applied to 13x and trunk.

        Show
        Donald Woods added a comment - Applied to 13x and trunk.
        Donald Woods made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 1.2.3 [ 12314517 ]
        Resolution Fixed [ 1 ]
        Hide
        Donald Woods added a comment -

        Heath will be adding a testcase patch and Mike will be pulling into 1.2.3.

        Show
        Donald Woods added a comment - Heath will be adding a testcase patch and Mike will be pulling into 1.2.3.
        Donald Woods made changes -
        Resolution Fixed [ 1 ]
        Status Resolved [ 5 ] Reopened [ 4 ]
        Donald Woods made changes -
        Fix Version/s 1.2.3 [ 12314517 ]
        Hide
        Heath Thomann added a comment - - edited

        Attaching the final version of the code changes and a test case. The patch contains both code changes and test case.

        Show
        Heath Thomann added a comment - - edited Attaching the final version of the code changes and a test case. The patch contains both code changes and test case.
        Heath Thomann made changes -
        Attachment OPENJPA-1550.diff.txt [ 12438943 ]
        Heath Thomann made changes -
        Attachment OPENJPA-1550.diff.txt [ 12437968 ]
        Hide
        Heath Thomann added a comment -

        Adding updated patch for 1.3.x and truck which contains code changes and a new test case.

        Show
        Heath Thomann added a comment - Adding updated patch for 1.3.x and truck which contains code changes and a new test case.
        Heath Thomann made changes -
        Attachment OPENJPA-1550-13x-testcase.patch.txt [ 12439116 ]
        Attachment OPENJPA-1550-trunk-testcase.patch.txt [ 12439117 ]
        Donald Woods made changes -
        Status Reopened [ 4 ] In Progress [ 3 ]
        Hide
        Donald Woods added a comment -

        Mike has already applied the patches to 1.2.x branch.
        Updated 1.3.x patch applied as r924766.
        Working on trunk updates now, but seeing 6 test failures in the new TestBatchLimitException.

        Show
        Donald Woods added a comment - Mike has already applied the patches to 1.2.x branch. Updated 1.3.x patch applied as r924766. Working on trunk updates now, but seeing 6 test failures in the new TestBatchLimitException.
        Hide
        Heath Thomann added a comment -

        Adding code to allow the 'failed object' to percolate up to the RollbackException.

        Show
        Heath Thomann added a comment - Adding code to allow the 'failed object' to percolate up to the RollbackException.
        Heath Thomann made changes -
        Attachment OPENJPA-1550v2.diff.txt [ 12439718 ]
        Attachment OPENJPA-1550-13x-v2.diff.txt [ 12439719 ]
        Attachment OPENJPA-1550-trunk-testcase.patch.txt [ 12439720 ]
        Heath Thomann made changes -
        Attachment OPENJPA-1550-trunk-testcase.patch.txt [ 12439117 ]
        Hide
        Heath Thomann added a comment -

        Let me comments on the patches I just attached:

        OPENJPA-1550v2.diff.txt is for 1.2.x.
        OPENJPA-1550-13x-v2.diff.txt is for 1.3.x
        OPENJPA-1550-trunk-testcase.patch.txt is for trunk.

        These patches add code to allow the 'failed object' to percolate up to the RollbackException which results in the use case.
        In addition, the trunk version of the patch fixes the test failures as outline by Donald.

        For history sake, let me comment on the other patches already committed:

        These patches are for 1.3.x:
        OPENJPA-1550-13x.patch - this is the initial code change committed.
        OPENJPA-1550-13x-testcase.patch.txt - this one adds some additional code plus the test case.

        This patch is for trunk:
        OPENJPA-1550-trunk.patch - this is the initial code change committed.

        And this patch is for 1.2.x:
        OPENJPA-1550.diff.txt - this is the initial code change committed plus the test case.

        Show
        Heath Thomann added a comment - Let me comments on the patches I just attached: OPENJPA-1550 v2.diff.txt is for 1.2.x. OPENJPA-1550 -13x-v2.diff.txt is for 1.3.x OPENJPA-1550 -trunk-testcase.patch.txt is for trunk. These patches add code to allow the 'failed object' to percolate up to the RollbackException which results in the use case. In addition, the trunk version of the patch fixes the test failures as outline by Donald. For history sake, let me comment on the other patches already committed: These patches are for 1.3.x: OPENJPA-1550 -13x.patch - this is the initial code change committed. OPENJPA-1550 -13x-testcase.patch.txt - this one adds some additional code plus the test case. This patch is for trunk: OPENJPA-1550 -trunk.patch - this is the initial code change committed. And this patch is for 1.2.x: OPENJPA-1550 .diff.txt - this is the initial code change committed plus the test case.
        Hide
        Michael Dick added a comment -

        Thanks for the patches Heath. I've committed to 1.3.x, with the other releases coming when the sanity builds complete.

        Show
        Michael Dick added a comment - Thanks for the patches Heath. I've committed to 1.3.x, with the other releases coming when the sanity builds complete.
        Hide
        Michael Dick added a comment -

        Committed Heath's latest patch on trunk, 2.0.x and 1.2.x.

        Show
        Michael Dick added a comment - Committed Heath's latest patch on trunk, 2.0.x and 1.2.x.
        Michael Dick made changes -
        Status In Progress [ 3 ] Resolved [ 5 ]
        Fix Version/s 2.1.0 [ 12314542 ]
        Resolution Fixed [ 1 ]
        Donald Woods made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Donald Woods
            Reporter:
            Heath Thomann
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development