I have a DB running on Oracle. I use Hibernate for data access. I want to be notified whenever an object is saved in the DB, so that I can do some custom work. I want an "event listener" if you could call it that. Is there a way to detect such task ?
+1
A:
On Hibernate level, this is done using interceptors
On Oracle level, it's called trigger:
create or replace trigger <triggername>
before/after insert or update or delete
on <tablename>
for each row/for each statement
...
mhaller
2009-11-04 09:46:51
is it possible instead to use interceptors in Hibernate to intercept a persistent object before it is saved, updated or deleted ?
Attilah
2009-11-04 17:05:40
sorry, i made a mistake . is it possible instead to use interceptors in Hibernate to intercept a persistent object <b>AFTER</b> it is saved, updated or deleted ?
Attilah
2009-11-04 17:07:11
Have you looked into the Interceptor example? See the afterTransactionCompletion() method, which is called AFTER the object is saved/updated/deleted.
mhaller
2009-11-05 14:11:22
hi mhaller, thanks for telling me about Hibernate interceptors but I can't make it work even though I followed the reference step by step : http://stackoverflow.com/questions/1701793/hibernate-interceptors-aftertransactioncompletion
Attilah
2009-11-09 20:28:47