Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » reading new primary key of inserted object
reading new primary key of inserted object [message #641362] Thu, 25 November 2010 08:18 Go to next message
Manuel is currently offline ManuelFriend
Messages: 5
Registered: October 2010
Junior Member

We use an Oracle 10g database and EclipseLink 2.1.1, without JPA.
When i insert a new object into the database with the UnitOfWork-Object by calling registerNewObject and commit, the primary key (NUMBER) is generated with a database sequence called by a database trigger on insert action.

The question is:
How can i read the new generated primary key back to my application???

i'm a bit confused about this. Any ideas or hints how this works?

Re: reading new primary key of inserted object [message #641473 is a reply to message #641362] Thu, 25 November 2010 15:35 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

You can use the ReturningPolicy in EclipseLink to do this.

I would recommend however that you let EclipseLink assign the value and remove the trigger, or have the trigger do nothing if the id is already assigned.

This will allow EclipseLink to preallocate the sequence values, and be much more efficient.

James : Wiki : Book : Blog : Twitter
Previous Topic:query-by-example and trim?
Next Topic:DB2 XML Column
Goto Forum:

Current Time: Mon Jun 18 23:28:09 GMT 2018

Powered by FUDForum. Page generated in 0.01908 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top