3 Replies Latest reply on Jun 8, 2011 2:31 PM by Adam Warski

    Envers auditing only the last update/insert

    Sri Harsha Yenuganti Newbie

      I am using hibernate with a datasource with container managed transactions. Even though I making a lot of updates/inserts in the whole process, only the last update is being audited. But I can see that the listeners are fired for every update/insert.


      Why is Envers skipping all other changes and why is it auditing only the last update even though the listeners are fired for all the updates?


      Here is the piece of code I am trying to work with:



                                        session = SessionFactoryUtil.getInstance().getCurrentSession();

                         OrderRequestId orderKey = new OrderRequestId();





                        OrderRequest orderRecord = (OrderRequest) session.get(OrderRequest.class,orderKey);


                        orderRecord.setHsuTs(new Date());





                          }catch (Exception ex) {





      I have similar piece of code to update many tables. But when I run the app only the last update is audited.


      Can any one help me please?

        • 1. Re: Envers auditing only the last update/insert
          Sri Harsha Yenuganti Newbie



          Can you please help me in this? Time is runing out for us. This is the only thing that is holding us from going to production. If I dont find a solution, I have to audit everything manually.


          How can I know if all the updates are being collected or not? How can I check it?

          • 2. Re: Envers auditing only the last update/insert
            Sri Harsha Yenuganti Newbie

            I have downloaded all the Hibernate+Envers code and added it to my project to see whats happening.


            When the beforeCommitTransaction method is called on AuditListener, I can see only one work unit to be audited. It is not accumulating all the work units through out the transaction. I have checked that the session used to do the insert/updates is the same one for all the operations. So audit process manager should return the same audit process. But in the end when I try to print the work units, there is only one work unit i.e., the last insert/update. All the updates occur inside a application server controlled transaction that spans the whole application(BPEL) and commits at the end of the BPEL. The session flush mode is AUTO.


            Why are all others not accumulated in the work units list?

            • 3. Re: Envers auditing only the last update/insert
              Adam Warski Master

              Hmm that's really strange. I don't have any ideas unfortunately.

              Which Application Server are you using?

              Can you take a look at AuditProcessManager and debug if the AuditProcess is properly found? It should be the same one for the whole transaction.