Recently, I came across a situation where I need to perform some actions when an object is updated through a Hibernate session , but there are no methods in the hibernate session where I can add an update listener. To summarize my intentions, I am sending a sample program.
public class SessionListenerTest{ public static void main(String[] args){ ... Session session = sessionFactory.openSession(); session.addSessionListener(new SessionListener(){ onUpdate(Object dbObject){ ... } onDelete(Object dbObject){ ... } onInsert(Object dbObject){ ... } }); } }
When the ant object is updated through a sleep session, onUpdate should be called , and so on. But a Hibernate session does not have methods similar to addSessionListener . Any help is appreciated.
source share