Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » @GeneratedValue strategy for History Policy(Whats the right strategy when using an entity with a HistoryPolicy)
@GeneratedValue strategy for History Policy [message #895156] Wed, 11 July 2012 20:15 Go to next message
Nick Padilla is currently offline Nick PadillaFriend
Messages: 16
Registered: August 2011
Location: New Mexico
Junior Member
Hello All,

I have been trying to get Auditing/History going for my application. I am not sure what else to do here. I have created my entities using a @MappedSuperclass that contains the @Id and @GeneratedValue. So far so good. Without the @Customizer everything works as expected. When you update the object it keeps the id already assigned. No errors or problems. However when I enable the HistoryPolicy, i just extended the base class so that eclipselink can create the table, it throws Primary Key errors since it is trying to do an insert of an updated row with an already used ID. I have tried to use SEQUENCE and AUTO as the strategies and started out with IDENTITY, however they all throw the same error. I am using EclipseLink 2.4 snapshot and JDK7. I don't think the @MappedSuperclass has anything to do with the problem, I believe it to be a bug in the EclipseLink HistoryPolicy implementation. In reality I shouldn't have to change the entity to ensure the @Id is setup correctly, however I did that as well but same problem. JPA2 requires a PRIMARY key for all Entities so not sure how to implement this so that it works. What I want to do is to have Two Entities - one the 'live' entity and another the 'history' entity. I will only use the history entities as read only so show the audit/history trail of the objects.

Any questions or ideas would be greatly appreciated.

Re: @GeneratedValue strategy for History Policy [message #899635 is a reply to message #895156] Wed, 01 August 2012 15:57 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

I think this is bug#347539

The issue is with IDENTITY id generation and history. Try using TABLE sequencing.

James : Wiki : Book : Blog : Twitter
Previous Topic:(no subject)
Next Topic:difference between PESSIMISTIC_WRITE and read?
Goto Forum:

Current Time: Fri Apr 20 05:24:03 GMT 2018

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

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