Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 305
Mapping documents: not important
i wrote my event class like this:
Code:
/* (non-Javadoc)
* @see org.hibernate.event.def.DefaultPostUpdateEventListener#onPostUpdate(org.hibernate.event.PostUpdateEvent)
*/
public void onPostUpdate(PostUpdateEvent event) {
super.onPostUpdate(event);
Object bean = event.getEntity();
if (bean instanceof Parametro){
Dominio oldDom = (Dominio)event.getOldState()[0];
Dominio newDom = (Dominio)event.getState()[0];
//Controllo che il codice dominio nuovo è diverso dal vecchio
//se lo è cancello tutte le relazioni del parametro
if (newDom.getCodint() != oldDom.getCodint()){
Parametro par = (Parametro)bean;
par.getRelazioni().removeAll(par.getRelazioni());
}
}
}
The problem is: i think in event.getOldState() was store the old state of my bean but oldstate is always NULL. Why?
i need to compare the oldstate with new state of bean what could i do?
thanks