5 Replies Latest reply on Sep 28, 2012 9:55 AM by Adam Warski

    Conditional Auditing - entering into infinite loop

    Praveen Gajjala Newbie

      I am trying  not to insert the duplicate records into audit tables. So, I compare the entity with the old entity in the database and audit only if its modified. In the process of fetching the old entity,it fires the onPostUpdate event again and enters into infinite loop. The hibernate createQuery to fetch the old entity is internally firing an update action which is making an infinite loop.


      Is there a way I can fix this issue ?



      My code :


      public class CustomAuditEventListener extends AuditEventListener  {




          public void onPostUpdate(PostUpdateEvent event){








          private boolean isEntityModified(Object entity) {


                  if(entity instanceof MyClass){

                        MyClass oldEntity = ContextUtil.getManager().find(((MyClass) entity).getId());

                        return !((MyClass) entity).isAuditEquals(oldEntity);



              return true;






      FYI, I am using hibernate 3.5.5