Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » How to obtain the entity ID after persit from a trigger generated value(How to obtain the entity ID after persit from a trigger generated value)
icon5.gif  How to obtain the entity ID after persit from a trigger generated value [message #1017084] Fri, 08 March 2013 16:51 Go to next message
Scott Selvia is currently offline Scott Selvia
Messages: 8
Registered: April 2010
Junior Member
We are using eclipselink via Glassfish 3+, our oracle table has a trigger that generates a PK VARCHAR value from a trigger. The value is generated from the CCYYMMDD of the current date and a sequence value. We can persist the entity without issues but we cannot figure out how to obtain the entity @ID value once the object has been persisted. We set the id value to null when the object is initialized, the id value is then generated by the trigger. We've tried to get the id after the persist with a flush and/or refresh but it's not working.

The trigger and the ID value is controlled by the DBA's and the requirements for the application.

Any solutions to the problem...Thanks.

[Updated on: Fri, 08 March 2013 17:05]

Report message to a moderator

Re: How to obtain the entity ID after persit from a trigger generated value [message #1018820 is a reply to message #1017084] Thu, 14 March 2013 10:28 Go to previous message
Chris Delahunt is currently offline Chris Delahunt
Messages: 1016
Registered: July 2009
Senior Member
You might be able to use @ReturnInsert on the @ID field as described here:
http://www.eclipse.org/eclipselink/documentation/2.4/jpa/extensions/a_returninsert.htm#CIHHEGJE

This has draw backs though, as the sequence cannot be preallocated and so not available until after the persist call has been flushed.

Best Regards,
Chris
Previous Topic:JPA-RS: @OneToMany: invalid output when retrieving relationship link
Next Topic:strange problem with error cvc-elt.1 and name space
Goto Forum:
  


Current Time: Tue Jul 22 23:47:42 EDT 2014

Powered by FUDForum. Page generated in 0.02661 seconds