Hi,
How to determine if entity fields are changed or not ?
Right now i am comparing previous field values with current field values. This is too boring if you need to check more than one type of entity. Is there any other way to learn if a change occured or not ? I want to raise an event after i certainly sure that some fields values are changed. ( I mean real change different than the previous field. Some times even i need to check that if updated value is empty or not to prevent any event call. )
@Name("profileViewHome") public class ProfileViewHome extends EntityHome<Member> { ... ... @Override public String update() { String result=super.update(); // result is always returns updated i want to learn if there is a real change if(result.equals("updated")){ // Here i have to decide which events are need to be // raised just looking related fields if(status field is changed) events.instance().raiseEvent("StatusChangedEvent",member.getId()); if(profile fields are changed) events.instance().raiseEvent("ProfileChangedEvent",member.getId()); } } ... ... }
Thanks.
No easy way, AFIK. You best bet is HibernateSession.isDirty(). That, of course, won't work if you are using manual flush.