OpenJPA
  1. OpenJPA
  2. OPENJPA-1260

Wrong sequence is generated for custom native sequence generator from getIdGenerator.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.3.0, 2.0.0
    • Fix Version/s: 1.1.1, 1.3.0, 2.0.0-M3
    • Component/s: sql
    • Labels:
      None
    • Patch Info:
      Patch Available
    1. openJPA-1260_1.1.x.patch
      9 kB
      Ravi P Palacherla
    2. OPENJPA-1260-trunk.patch
      7 kB
      Ravi P Palacherla
    3. OPENJPA-1260-trunk.patch
      7 kB
      Ravi P Palacherla

      Activity

      Ravi P Palacherla created issue -
      Hide
      Ravi P Palacherla added a comment -

      OpenJPAEntityManager.getIdGenerator.next() fails to generate correct sequence number when class uses native sequence geneartor.

      The cause of the issue is OpenJPAEntityManager.getIdGenerator.next() goes against the default sequence openjpa_sequence rather than the defined sequence.
      So the SQL on openjpaentitymanager.getIdGenerator.next() is
      SELECT SEQUENCE_VALUE FROM OPENJPA_SEQUENCE_TABLE WHERE ID = ? FOR UPDATE
      even though a native sequence generator is defined.

      @Id
      @GeneratedValue(strategy=GenerationType.SEQUENCE,
      generator="entityE2_seq_gen_name")
      @SequenceGenerator(name="entityE2_seq_gen_name",
      sequenceName="entityE2_seq_gen")
      private int id;

      Show
      Ravi P Palacherla added a comment - OpenJPAEntityManager.getIdGenerator.next() fails to generate correct sequence number when class uses native sequence geneartor. The cause of the issue is OpenJPAEntityManager.getIdGenerator.next() goes against the default sequence openjpa_sequence rather than the defined sequence. So the SQL on openjpaentitymanager.getIdGenerator.next() is SELECT SEQUENCE_VALUE FROM OPENJPA_SEQUENCE_TABLE WHERE ID = ? FOR UPDATE even though a native sequence generator is defined. @Id @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="entityE2_seq_gen_name") @SequenceGenerator(name="entityE2_seq_gen_name", sequenceName="entityE2_seq_gen") private int id;
      Hide
      Ravi P Palacherla added a comment -

      Testcase & Fix.

      Show
      Ravi P Palacherla added a comment - Testcase & Fix.
      Ravi P Palacherla made changes -
      Field Original Value New Value
      Attachment OPENJPA-1260-trunk.patch [ 12417398 ]
      Ravi P Palacherla made changes -
      Patch Info [Patch Available]
      Hide
      Michael Dick added a comment -

      Hi Ravi,

      The patch looks good but I'd recommend moving the testcase to a different package, org.apache.openjpa.persistence.jdbc.sequence or just org.apache.openjpa.persistence.sequence. The testcase isn't using delimited identifiers so it'd be a bit misleading to put it in that package.

      Otherwise the patch looks great.

      Show
      Michael Dick added a comment - Hi Ravi, The patch looks good but I'd recommend moving the testcase to a different package, org.apache.openjpa.persistence.jdbc.sequence or just org.apache.openjpa.persistence.sequence. The testcase isn't using delimited identifiers so it'd be a bit misleading to put it in that package. Otherwise the patch looks great.
      Hide
      Ravi P Palacherla added a comment -

      Uploaded patch with new package and class name.

      Show
      Ravi P Palacherla added a comment - Uploaded patch with new package and class name.
      Ravi P Palacherla made changes -
      Attachment OPENJPA-1260-trunk.patch [ 12417496 ]
      Ravi P Palacherla made changes -
      Attachment OPENJPA-1260-trunk.patch [ 12417522 ]
      Ravi P Palacherla made changes -
      Attachment OPENJPA-1260-trunk.patch [ 12417496 ]
      Donald Woods made changes -
      Fix Version/s 2.0.0 [ 12314019 ]
      Hide
      Donald Woods added a comment -

      Modified patch committed to trunk by Kevin Sutter in r813597 and back ported to 1.3.0 by Donald Woods in r813868.

      Show
      Donald Woods added a comment - Modified patch committed to trunk by Kevin Sutter in r813597 and back ported to 1.3.0 by Donald Woods in r813868.
      Donald Woods made changes -
      Assignee Ravi P Palacherla [ rpalache ] Michael Dick [ mikedd ]
      Fix Version/s 1.3.0 [ 12313326 ]
      Fix Version/s 2.0.0-M3 [ 12314148 ]
      Fix Version/s 2.0.0 [ 12314019 ]
      Affects Version/s 1.3.0 [ 12313326 ]
      Hide
      Donald Woods added a comment -

      Mike, please reopen if you want to apply this to 1.2.x or 1.0.x.

      Show
      Donald Woods added a comment - Mike, please reopen if you want to apply this to 1.2.x or 1.0.x.
      Donald Woods made changes -
      Status Open [ 1 ] Resolved [ 5 ]
      Resolution Fixed [ 1 ]
      Ravi P Palacherla made changes -
      Attachment openJPA-1260_1.1.x.patch [ 12427136 ]
      Hide
      David Ezzio added a comment -

      Applied Ravi's 1.1.x patch at revision 890402

      Show
      David Ezzio added a comment - Applied Ravi's 1.1.x patch at revision 890402
      David Ezzio made changes -
      Fix Version/s 1.1.1 [ 12313177 ]
      Donald Woods made changes -
      Status Resolved [ 5 ] Closed [ 6 ]
      Transition Time In Source Status Execution Times Last Executer Last Execution Date
      Open Open Resolved Resolved
      19d 2h 41m 1 Donald Woods 11/Sep/09 16:07
      Resolved Resolved Closed Closed
      179d 3h 24m 1 Donald Woods 09/Mar/10 18:31

        People

        • Assignee:
          Michael Dick
          Reporter:
          Ravi P Palacherla
        • Votes:
          0 Vote for this issue
          Watchers:
          0 Start watching this issue

          Dates

          • Created:
            Updated:
            Resolved:

            Development