I test solution with Event listeners and it not work.
Event listener definition (with Spring, but this the same as in hibernate.cfg.xml):
Code:
<property name="eventListeners">
<map>
<entry key="post-update">
<reflocal="deviceUpdateListener"/></entry>
</map>
</property>
<bean id="updateListener"
class="cluster.UpdateListener"/>
Class definition:
Code:
public class UpdateListener implements PostUpdateEventListener {
public void onPostUpdate(PostUpdateEvent event) {
System.out.println("PostUpdateEventListener.onPostUpdate");
}
}
Code fragment:
Code:
Session s=getHibernateTemplate().
getSessionFactory().getCurrentSession();
Query q=s.createQuery("update versioned User w set w.userName=:name");
q.setString("name", "Alex");
q.executeUpdate();
This didn't affect event listener. But use session.update() affect event listener with the same configuration.