[ https://issues.apache.org/jira/browse/OPENJPA-736?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12702866#action_12702866 ]
Milosz Tylenda commented on OPENJPA-736: ---------------------------------------- Omitting an identity column is not the problem. The MySQL issue is that it does not allow the retrieval of generated column by its actual name - coulmn name is always "GENERATED_KEY". The PostgreSQL issue is that it requires exact case in column name passed to Connection.prepareStatement("insert into IdentityGenerationType (someData) values('gktest')", new String[] {"orderid[case matters here]"}); Looks like the solution is to pass identity column name thru DBDictionary case conversion and to get generated column value by using column index. MySQL, PostgreSQL and DB2 accept this. I will see what about MS SQL Server when I manage to install it. The MS JDBC 2.0 driver suggests it behaves much like MySQL [1]. [1] http://msdn.microsoft.com/en-us/library/ms378445.aspx > 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.