| retrieving the assigned primary key [message #489625] |
Mon, 05 October 2009 07:58  |
Tom Eugelink Messages: 801 Registered: July 2009 |
Senior Member |
|
|
I've moved a piece of code to native queries because of locking and conflicts with Eclipselinks' cache. But on the boundary between Eclipselink and native I need to be able to access the primary keys that Eclipselink assigned to newly inserted entities. In this specific scenario it's the PK of an entity that is persisted by reference in a 1-N relation. Is there any way to find the PK that is assigned to a entity immediately after the pk was created from the sequence table?
The other approach would be for me to set that primary key myself. That I will test now.
Tom
|
|
|
|
|
|
|
| Re: retrieving the assigned primary key [message #492215 is a reply to message #491696] |
Mon, 19 October 2009 09:48  |
James Sutherland Messages: 1844 Registered: July 2009 |
Senior Member |
|
|
Objects persisted through cascade persist will still have an Id assigned. If using IDENTITY you must call flush().
If you are not noticing the Id assigned, then what is being inserted into the database on flush or commit?
Are you should your relationship is cascade persist, also check to ensure you don't have multiple copies of the same object registered.
James : Wiki : Book : Blog
|
|
|
Powered by
FUDForum. Page generated in 0.01951 seconds