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

    Envers auditing only the last update/insert

    shyenuganti

      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:

       

               try{

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

                         OrderRequestId orderKey = new OrderRequestId();

                                              orderKey.setBatchNumber(...);

                                              orderKey.setDln(...);

                                              orderKey.setTransNumber(...);

       

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

                                 

                        orderRecord.setHsuTs(new Date());

                        orderRecord.setHsuUsrId("TEST");

                        session.flush();

                        

                        

                          }catch (Exception ex) {

                    ex.printStackTrace();

               }

       

       

      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
          shyenuganti

          Adam,

           

          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
            shyenuganti

            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
              adamw

              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.

               

              Adam