aspose file tools
The moose likes Object Relational Mapping and the fly likes how to find which attributes have changed before using merge() in EclipseLink? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "how to find which attributes have changed before using merge() in EclipseLink?" Watch "how to find which attributes have changed before using merge() in EclipseLink?" New topic
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
 
IntelliJ Java IDE
 
subject: how to find which attributes have changed before using merge() in EclipseLink?
 
Threads others viewed
Questions about LAZY and EAGER loading (JPA 1.0)
Getting User inputs to Connection Bean
Audit Log
Issue in submitting the Form with Arraylist in Struts 1.1
Distributed Caching
developer file tools