Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » How to approach data tracking?(So that updates to the database INSERT instead of UPDATE)
How to approach data tracking? [message #522017] Fri, 19 March 2010 16:14 Go to next message
Carlos Conti is currently offline Carlos ContiFriend
Messages: 26
Registered: January 2010
Junior Member
Hi all,

I am newbie to JPA and have been developing an essay application for my organisation. Currently I am almost at the end of it, but there remains an issue regarding data tracking in the backend database.

Currently I have come to record data in a 'record per instance' manner. This model doesn't allow me to track changes in a userfriendly way. I can figure out tricky ways of doing it, if I must unavoidably stick to this way of doing things. However I am sure there must be an easier way to build it with another pk strategy.

I would like to adopt a double primarykey where in one field I would have my currently automatically created id (through an 'Identity' pk generation strategy), and in the second field I would have a DELETED flag such as {0,1}.

If possible I would appreciate if someone could give me a hint on how to get there.

Thanks in advance for your help!
Carlos.
Re: How to approach data tracking? [message #522040 is a reply to message #522017] Fri, 19 March 2010 13:34 Go to previous messageGo to next message
Tom Eugelink is currently offline Tom EugelinkFriend
Messages: 817
Registered: July 2009
Senior Member
> This model doesn't allow me to track changes in a userfriendly way.

If your problem is solved by keeping a history of changes; Eclipselink supports storing old versions of a record in a separate history table, together with a valid from-until timestamp pair.

Tom
Re: How to approach data tracking? [message #522050 is a reply to message #522040] Fri, 19 March 2010 18:40 Go to previous messageGo to next message
Carlos Conti is currently offline Carlos ContiFriend
Messages: 26
Registered: January 2010
Junior Member
Cool!, but where do you specify that?

I am using the JPA Eclipse IDE to write the ORM file, and so far haven't seen any reference to what you're saying. Could you tell me in which context must I define that? entity context?, persistence context?, I presume entitycontext...

should I create a secondary table for that? and then how do I specify I want to add an old record...

thanks!
Carlos.
Re: How to approach data tracking? [message #522085 is a reply to message #522050] Fri, 19 March 2010 16:26 Go to previous messageGo to next message
Tom Eugelink is currently offline Tom EugelinkFriend
Messages: 817
Registered: July 2009
Senior Member
On 2010-03-19 19:40, Carlos Conti wrote:
> Cool!, but where do you specify that?

http://wiki.eclipse.org/Configuring_a_Descriptor_(ELUG)#Conf iguring_a_History_Policy

> should I create a secondary table for that? and then how do I specify I
> want to add an old record...

The history table is an exact copy of the actual table plus two fields. A new record is added to the history table as soon as the original record is updated. Works like a charm for me.

Tom
icon14.gif  Re: How to approach data tracking? [message #528278 is a reply to message #522085] Mon, 19 April 2010 22:12 Go to previous message
Carlos Conti is currently offline Carlos ContiFriend
Messages: 26
Registered: January 2010
Junior Member
Cool Tom.
Thanks for your explanation. I'm sure I will be able to get forward.

Sorry for my late response.
Carlos.
Previous Topic:cascade delete not working when cache is active
Next Topic:Reading entity beans from Glassfish too slow
Goto Forum:
  


Current Time: Thu Apr 25 02:21:37 GMT 2024

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

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

Back to the top