Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » keeping a history: who done it?
keeping a history: who done it? [message #503456] Mon, 14 December 2009 09:48 Go to next message
Tom Eugelink is currently offline Tom EugelinkFriend
Messages: 817
Registered: July 2009
Senior Member
Does Eclipselink's history also support a "modified by" field?


I'm slowing replacing my old history keeping system with Eclipselink's approach. My old system hooked into the PCE's of a bean and used these to alter a "modified at" property. This property is used to trigger a history keeping logic.

One of the drawbacks of my approach is that unnecessary changes are recorded. If a child is changed, it fires a PCE and a copy (correctly) ends up in the history. But if a child is added or removed, the parent's collection-of-childeren is changed, and this also results in a PCE, so a copy of the parent also is placed in the history, even though none of the parent's actually stored properties have changed.

By relying on Eclipselink I can stop setting the "modified at" property and the unnecessary history records should go away, except there also is a "modified by" property. It is always very handy to know who to talk to if some change does not make sense. This property also is bound to the PCE, like modified by, so it still marks the parent as changed (if a different user from the previous is making a change naturally).

Tom
Re: keeping a history: who done it? [message #503777 is a reply to message #503456] Tue, 15 December 2009 17:22 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

To keep track of a user modified by field, it is easiest to add the field to your object and update it when the object changes (such as using the PreUpdate event).

See,
http://en.wikibooks.org/wiki/Java_Persistence/Advanced_Topic s#Auditing

With EclipseLink you can also use the DescriptorEvent API to implement an aboutToUpdate event to append the user to the row, so don't require adding the field to your object if you don't want to.


James : Wiki : Book : Blog : Twitter
Re: keeping a history: who done it? [message #503786 is a reply to message #503777] Tue, 15 December 2009 18:40 Go to previous messageGo to next message
Tom Eugelink is currently offline Tom EugelinkFriend
Messages: 817
Registered: July 2009
Senior Member
> To keep track of a user modified by field, it is easiest to add the
> field to your object and update it when the object changes (such as
> using the PreUpdate event).

Yes, of course, instead of using PCE's, use the events of the persisting engine. How short sighted again.

Thanks.

Tom
Re: keeping a history: who done it? [message #504095 is a reply to message #503777] Thu, 17 December 2009 08:52 Go to previous message
Tom Eugelink is currently offline Tom EugelinkFriend
Messages: 817
Registered: July 2009
Senior Member
> To keep track of a user modified by field, it is easiest to add the
> field to your object and update it when the object changes (such as
> using the PreUpdate event).

I switched to Eclipselink events instead of JPA's last week, and preInsert() and preUpdateWithChanges() seem to work fine (preUpdate() is called on way too much entities).
Previous Topic:JPA 2.0 non-jta-data-source issue
Next Topic:Bug with IndirectMap?
Goto Forum:
  


Current Time: Tue Mar 19 09:25:12 GMT 2024

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

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

Back to the top