| Author |
how to find which attributes have changed before using merge() in EclipseLink?
|
nicolas diogo
Greenhorn
Joined: Nov 03, 2011
Posts: 11
|
|
hi,
i would like to find out if there is a way of knowing which attribute has changed in an entity managed by EclipseLink.
i have to implement a business rule if different attributes are updated - but i do not know how to 'compare' the new values that were updated against those that exist in the database.
i would appreciate if you could post links to documentation about this. i have searched but i doubt that i am using the correct terminology on this subject.
thanks a lot,
Nicolas
|
 |
Hebert Coelho
Ranch Hand
Joined: Jul 14, 2010
Posts: 718
|
|
There is no way to know that in an automatic way.
If you really need to know the changes you could do a find, and compare each attribute.
|
[uaiHebert.com] [Full WebApplication JSF EJB JPA JAAS with source code to download] One Table Per SubClass [Web/JSF]
|
 |
nicolas diogo
Greenhorn
Joined: Nov 03, 2011
Posts: 11
|
|
thanks
how do i implement your suggestion of 'find'
i do not really understand what you have meant by it.
|
 |
Hebert Coelho
Ranch Hand
Joined: Jul 14, 2010
Posts: 718
|
|
I would be something like:
|
 |
James Sutherland
Ranch Hand
Joined: Oct 01, 2007
Posts: 472
|
|
After you merge, you can get the objects changeSet (by casting to ChangeTracker if weaving change tracking, or calling UnitOfWork.getCurrentChanges()).
Before the merge, not sure they is a public API, but there is ObjectBuilder.compareForChange (or merge into a temporary persistence context).
|
TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
|
 |
 |
|
|
subject: how to find which attributes have changed before using merge() in EclipseLink?
|
|
|