Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to find which attributes have changed before using merge() in EclipseLink?

 
nicolas diogo
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 754
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
nicolas diogo
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks

how do i implement your suggestion of 'find'
i do not really understand what you have meant by it.

 
Hebert Coelho
Ranch Hand
Posts: 754
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would be something like:
 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic