[ 
https://issues.apache.org/jira/browse/OPENJPA-736?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Milosz Tylenda reopened OPENJPA-736:
------------------------------------

      Assignee: Milosz Tylenda  (was: Fay Wang)

More work is needed. The problem is that when a table has an identity 
(auto-increment) column, we omit that column in INSERT statement and then we 
retrieve the generated (and omitted) column by name. DB2 accepts this but MySQL 
and PostgreSQL go on strike. Testing on other databases may reveal more 
oddities.
 
I will look into this.

For those interested, the JDBC driver for PostgreSQL, available in their CVS, 
supports the getGeneratedKeys variant OpenJPA would use. There is an unofficial 
build available [1] which contains that feature.

[1] http://ejurka.com/pgsql/jars/genkey/



> Combine insert and select SQL together for generated Id 
> strategy=GenerationType.IDENTITY 
> -----------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-736
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-736
>             Project: OpenJPA
>          Issue Type: Improvement
>    Affects Versions: 1.3.0
>            Reporter: Fay Wang
>            Assignee: Milosz Tylenda
>             Fix For: 1.3.0
>
>         Attachments: openjpa-736.patch
>
>
> 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 (?, ?, ?, ?) )

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to