in Hooks getOriginalValue for an embeddedlist returns null
OrientDB Version: 2.2.19
Java Version: 8
OS: CENTOS
Expected behavior
In Java hooks, getOriginalValue should return the embedded list before change.
Actual behavior
returns null
Steps to reproduce
getOriginalValue is returning null for embeddedList. we need to use getOriginalValue to see what was added to remove duplicates. We have records created as follows.
INSERT INTO V SET ID = 1; update #9:0 add blax = [13] select from #9:0
We used the sample hooks provided on the website and the code is as follows. Everytime we call add on an embedded list, the getOriginalValue returns null and the new value returns the entire list, not the just the new data.
` public RESULT onRecordBeforeUpdate(ODocument document) { System.out.println("Ran update hook"); for (String field : document.getDirtyFields()) { System.out.println("Field Modified:" + field); Object originalValue = document.getOriginalValue(field);
if (originalValue == null)
{
System.out.print("original value is null");
}
System.out.println("original value:" + originalValue);
System.out.println("new value:" + document.field(field));
}
return ORecordHook.RESULT.RECORD_NOT_CHANGED;
}`
Hi @SafwanHak
Thank you very much, we'll check it asap and let you know
Thanks
Luigi
hi @SafwanHak,
The original value is used only when the whole field is replaced in case of elements inside a collection the tracking is done using ODocument#getCollectionTimeLine that give a list of events of added an removed elements from the collection.
Hope this help.
Regards
Thanks, that makes sense, I'll give it a try, do you have examples of how to use it? Should I send an email for documentation to add this in the example, or will you take care of that? It's not obvious of course.
On Wed, May 3, 2017 at 12:01 PM, tglman [email protected] wrote:
hi @SafwanHak https://github.com/SafwanHak,
The original value is used only when the whole field is replaced in case of elements inside a collection the tracking is done using ODocument# getCollectionTimeLine that give a list of events of added an removed elements from the collection.
Hope this help.
Regards
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/orientechnologies/orientdb/issues/7385#issuecomment-298880802, or mute the thread https://github.com/notifications/unsubscribe-auth/ABxEo3OcpPM_CAXVxwfk6gWK_fV_RDnfks5r2F5vgaJpZM4NORz- .