开发者

Records not getting updated when PreUpdate listener is used in Hibernate

开发者 https://www.devze.com 2023-02-02 07:21 出处:网络
I amusing preupdate event listener concept in my database implemention. When I am adding listener as below the contenst in DB not getting updated.

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)

0

精彩评论

暂无评论...
验证码 换一张
取 消