Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » audit tracking(audit tracking business object life cycle with life cycle change listener)
audit tracking [message #523584] Fri, 26 March 2010 23:18 Go to next message
No real name is currently offline No real nameFriend
Messages: 3
Registered: March 2010
Junior Member
Hi,
Basically i have to track life cycle status changes of business objects and log from which status an object has migrated to which status. We do not want to track every change in data, but only those changes that have the targeted business value. We have to store this history for years and display it in appropriate screens.

In openJPA, i can configure restoreState to obtain the old state of the object. How could i achieve this with EclipseLink?

Will the life cycle change listeners for this purpose cause any performance deterioration? Our Architects advised that we solve it in Java rather than with PL/SQL triggers.What other solutions are available for audit tracking?

Could you please give me links to EclipseLink examples for audit tracking?

Thank you.
Re: audit tracking [message #523610 is a reply to message #523584] Sat, 27 March 2010 07:31 Go to previous messageGo to next message
Tom Eugelink is currently offline Tom EugelinkFriend
Messages: 817
Registered: July 2009
Senior Member
> In openJPA, i can configure restoreState to obtain the old state of the
> object. How could i achieve this with EclipseLink?

I know Eclipselink has a build-in function for keeping history, but that only does whole records, not single fields. But you can a.o. derive the history status changes from that table.

Eclipselink also has a fine grained event structure (similar to db triggers), so you could put in code there to store the status changes.

But I would simply go for the setStatus method. I assume you have an "HistoricalStatus" many-to-one entity bound to the actual entity, you could simply enhance the setStatus method to something like (I quickly put this together as an example):

public void setStatus(int status)
{
if (iLastHistoricalStatus == null || iLastHistoricalStatus.getStatus() != status)
{
if (iLastHistoricalStatus != null) removeHistoricalStatus(iLastHistoricalStatus);
iLastHistoricalStatus = new HistoricalStatus(iStatis);
addHistoricalStatus(iLastHistoricalStatus);
}
iStatus = status;
}
@JpaAnnotation...
int iStatus = ...
volatile HistoricalStatus iLastHistoricalStatus = null;


This will add the last set status value as an entity to the actual entity.
Re: audit tracking [message #523917 is a reply to message #523584] Mon, 29 March 2010 19:41 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

In addition to JPA events EclipseLink has DescriptorEvents that are raised in more operations, and with additional information. There are events for preInsert/postInsert/aboutToInsert/Update/Delete. Each event has an ObjectChangeSet that contains the changes.

See,
DescriptorEventListener

and,
DescriptorEvent and ObjectChangeSet

You can also get a list of changes from the EclipseLink UnitOfWork, and can get the previous state of a object using getBackupClone (provided deferred change tracking is used).


James : Wiki : Book : Blog : Twitter
Previous Topic:Initialize EclipseLink at runtime
Next Topic:Elements of List in @OneToMany with @OrderColumn are not being sorted
Goto Forum:
  


Current Time: Tue Mar 19 04:20:33 GMT 2024

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

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

Back to the top