entitymanager - Hibernate Enitity Listener for named query delete operation -
for our application need impelement trigger using hibernate . 1 best solution come entity listerner using annotation , need listen particular entity change . every thing works except delete named queries , gives no event .
code implementation ** enity** -here added listener
@entity @eventlisteners(employeeeventlistener.class) public class employee { @id private string uid; @basic private calendar lastupdated;
entity listener -
listener takes entity modified asd performs intended operation
public class employeeeventlistener { @prepersist public void prepersist(object object) { employee employee = (employee)object; employee.setuid(uidgenerator.newuui()); employee.setlastupdated(calendar.getinstance()); } @postupdate public void postupdate(object object) { employee employee = (employee)object; employee.setlastupdated(calendar.getinstance()); } @prepersist , @postupdate worked when used save or saveorupdate on entity manager. when executing delete named query, no event @preremove , @postremove event delete ... please me here .
this not possible: the interceptor interface provides callbacks session application
, object deleted via native sql doesn't pass session, callback won't run
Comments
Post a Comment