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

            People

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

              Dates

              • Created:
                Updated:
                Resolved:

                Development