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 03:18 Go to next message
Manuel is currently offline Manuel
Messages: 5
Registered: October 2010
Junior Member
Hi,

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?

Regards
MS
Re: reading new primary key of inserted object [message #641473 is a reply to message #641362] Thu, 25 November 2010 10:35 Go to previous message
James Sutherland is currently offline James Sutherland
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: Thu Jul 24 19:15:38 EDT 2014

Powered by FUDForum. Page generated in 0.06815 seconds