Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Audit Entity(Get old value)
icon5.gif  Audit Entity [message #838677] Sat, 07 April 2012 12:45 Go to next message
Oscar Hernandez is currently offline Oscar Hernandez
Messages: 5
Registered: April 2012
Junior Member

How to get the old value of a modified column?





public void postUpdate(DescriptorEvent event) {

for (String table : (List<String>)event.getDescriptor().getTableNames()) {


WriteObjectQuery query = (WriteObjectQuery) event.getQuery();
List<ChangeRecord> changes = query.getObjectChangeSet().getChanges();

for (int i = 0; i < changes.size(); i++)
{

if (changes.get(i) instanceof DirectToFieldChangeRecord)
{

DirectToFieldChangeRecord fieldChange = (DirectToFieldChangeRecord) changes.get(i);

System.out.println("Column: "+ fieldChange.getAttribute());
System.out.println("NewValue: "+ fieldChange.getNewValue().toString() );
//Get OldValue ???????????????????????

}
}

System.out.println("update");

}
}
icon5.gif  Re: Audit Entity [message #840093 is a reply to message #838677] Mon, 09 April 2012 16:45 Go to previous messageGo to next message
Oscar Hernandez is currently offline Oscar Hernandez
Messages: 5
Registered: April 2012
Junior Member
Hello. Help me please.

getOldValue not exists in Interface ChangeRecord.

ChangeRecord changeRecord = changes.get(i);
Object changeRecordOldValue = changeRecord.getOldValue();

index.php/fa/7828/0/
  • Attachment: error.png
    (Size: 233.25KB, Downloaded 427 times)
Re: Audit Entity [message #840094 is a reply to message #838677] Mon, 09 April 2012 16:48 Go to previous messageGo to next message
Oscar Hernandez is currently offline Oscar Hernandez
Messages: 5
Registered: April 2012
Junior Member
Hello. Help me please.

getOldValue not exists in Interface ChangeRecord.

ChangeRecord changeRecord = changes.get(i);
Object changeRecordOldValue = changeRecord.getOldValue();
  • Attachment: error.png
    (Size: 233.25KB, Downloaded 86 times)
Re: Audit Entity [message #840216 is a reply to message #840094] Mon, 09 April 2012 20:27 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris Delahunt
Messages: 1026
Registered: July 2009
Senior Member
This is discussed in an old thread here:
http://old.nabble.com/Fetch-original-state-of-the-object-td24488730.html

getOldValue() was added for use with Attribute Level Change Tracking in 2.2.0 for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=307433
Please check that you are using EclipseLink 2.2 or later to use this api.
icon5.gif  Re: Audit Entity [message #840246 is a reply to message #840216] Mon, 09 April 2012 21:27 Go to previous message
Oscar Hernandez is currently offline Oscar Hernandez
Messages: 5
Registered: April 2012
Junior Member
I saw the thread but did not understand, I could give an example. Thank you.
Previous Topic:JPA ManyToMany in case of users and groups?
Next Topic:JPA Query Paging : Query.setFirstResult(), Query.setMaxResults()
Goto Forum:
  


Current Time: Thu Oct 02 16:49:45 GMT 2014

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

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