OpenJPA
  1. OpenJPA
  2. OPENJPA-736

Combine insert and select SQL together for generated Id strategy=GenerationType.IDENTITY

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.3.0
    • Fix Version/s: 1.3.0, 2.0.0-M2
    • Component/s: None
    • Labels:
      None

      Description

      Currently if the strategy of the generated id is GenerationType.IDENTITY, when an entity object is created, openjpa will generate two SQL statements. The following is an example running on DB2:

      (1) INSERT INTO EntityA (col1, col2, col3, version) VALUES (?, ?, ?, ?)
      [params=(int) 1, (int) 1, (int) 1, (int) 1]

      (2) SELECT IDENTITY_VAL_LOCAL() FROM SYSIBM.SYSDUMMY1

      A performance improvement is to take advantage of the "select from final table" feature in DB2 to combine the insert and select statement into a single SQL statement as shown below:

      SELECT id FROM FINAL TABLE (INSERT INTO EntityA (col1, col2, col3, version) VALUES (?, ?, ?, ?) )

      1. supportsGetGeneratedKeys.patch
        2 kB
        Milosz Tylenda
      2. openjpa-736.patch
        7 kB
        Fay Wang

        Issue Links

          Activity

          Fay Wang created issue -
          Fay Wang made changes -
          Field Original Value New Value
          Assignee Fay Wang [ faywang ]
          Fay Wang made changes -
          Summary Combine insert and select SQL together when for generated Id with strategy=GenerationType.IDENTITY Combine insert and select SQL together for generated Id strategy=GenerationType.IDENTITY
          Fay Wang made changes -
          Attachment openjpa-736.patch [ 12391354 ]
          Fay Wang made changes -
          Resolution Fixed [ 1 ]
          Status Open [ 1 ] Resolved [ 5 ]
          Milosz Tylenda made changes -
          Link This issue is blocked by OPENJPA-847 [ OPENJPA-847 ]
          Milosz Tylenda made changes -
          Resolution Fixed [ 1 ]
          Status Resolved [ 5 ] Reopened [ 4 ]
          Assignee Fay Wang [ faywang ] Milosz Tylenda [ milosz ]
          Milosz Tylenda made changes -
          Attachment supportsGetGeneratedKeys.patch [ 12408877 ]
          Milosz Tylenda made changes -
          Status Reopened [ 4 ] Resolved [ 5 ]
          Fix Version/s 2.0.0 [ 12313483 ]
          Resolution Fixed [ 1 ]
          Donald Woods made changes -
          Status Resolved [ 5 ] Closed [ 6 ]

            People

            • Assignee:
              Milosz Tylenda
              Reporter:
              Fay Wang
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development