java - How to find which fields has been changed during @EntityListeners call -


let's assume have class :

@entitylisteners({mylistener.class}) class myclass {   string name;   string surname;    public string getname() {     return name;   }    public void setname(string name) {     this.name = name;    }    public string getsurname() {     return name;   }    public void setsurname(string name) {     this.name = name;    } } 

mylistener class :

public class mylistener {      private static final logger log = logger.getlogger(mylistener.class.getname());      public mylistener() {      }      @postpersist     @postupdate     @postremove     public void onpostpersist(myclass object) {         log.fine("firing changed entity event");     } } 

onpostpersist() method in mylistener class gets called on change of myclass instance field.

is possible find method has been called because of particular fields changes ?

eg: if changed name field alone,i should able find name field has been changed in last persist.

one way check comparing audit.

i know alter approach if available.

thanks

what describing makes sense update events. can register interceptor , listen changes in overridden onflushdirty method:

onflushdirty(object entity,              serializable id,              object[] currentstate,              object[] previousstate,              string[] propertynames,              type[] types) 

here have arrays of previous , current states , array of properties, can find out what's changed.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -