Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-736

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

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.3.0
    • 1.3.0, 2.0.0-M2
    • None
    • 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 (?, ?, ?, ?) )

      Attachments

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

        Issue Links

          Activity

            People

              milosz Milosz Tylenda
              faywang Fay Wang
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: