Records not getting updated when PreUpdate listener is used in Hibernate
I am using preupdate event listener concept in my database implemention.
When I am adding listener as below the contenst in DB not getting updated.
<property name="eventListeners">
<map>
<entry key="post-load">
<list>
<ref local="cisAuditLoadEventListener" />
</list>
</entry>
<entry key="pre-update">
<list>
<ref local="cisAuditLoadEventListener" />
</list>
</entry>
</property>
When I remove this listener (pre-update), update working fine.
In this pre-update listener i am inserting some records in db like audit records. I am able to insert them. But unable to update the records i want.
Below is the method i am overriding in a class which implements PreUpdateEventListener.
/*
* (non-Javadoc)
*
* @see
* org.hibernate.event.PreUpdateEventListener#onPreUpdate(org.hibernate.event
* .PreUpdateEvent)
*/
@Override
public boolean onPreUpdate(Pr开发者_JAVA百科eUpdateEvent event)
{
//insert data in db
}
Can any one help me regarding this problem.
Thanks,
Narendra
Make sure you return false
from that method. (i.e. the operation should not be vetoed)
精彩评论