10 Replies Latest reply on Dec 18, 2014 1:35 PM by martins.tuga

    Multiple Revisions per Transaction

    jmferland

      Hello, Community.

       

      I know I've seen this issue raised at least twice, but I would really like to be able to have multiple revisions per transaction. Why? So that if I perform more than one "step" or "action" within a transaction, I am still able to view each step as a revision. I don't want logical steps to be reduced into one single shared delta. I want to be able to retrace each step. The fact that they happened within a single transaction is merely a coincidence. At the very least this would offer flexibility. People wouldn't even need to do anything different. Envers would default to 1 revision per transaction. But, they could also create multiple revisions within a single transaction.

       

      Here's a contrived example:

       

      List<Action> actions = new ArrayList<Action>();
      actions.add(new RemoveFromBalance(someAccount, 10));
      actions.add(new AddToBalance(someAccount, 10));
      actions.add(new ChargeForLollipop(someAccount)); // also happens to modify the account balance
      actions.add(new CreditForSale(someAccount, someSale)); // adds commission from a sale to an account
      
      session.beginTransaction();
      for (Action action : actions) {
           action.doInSession(session);
           EnversUtil.flush(); // flushes session, flushes audit data, and creates a new revision entity
      }
      session.getTransaction().commit();
      

       

      I would like to see 4 revision entities involved that indicate 4 changes were made to "someAccount" and it happened to occur in a single transaction because some programmer used the API in that way. I would only see this because I specifically told Envers to flush. Perhaps the 4 revision entities could share a single transaction ID.

       

      Please let me know your thoughts.

       

      Jon