2 Replies Latest reply on Aug 21, 2012 8:08 AM by Dominik Neumayer

    Envers Set merge / ManyToOne Cascade Update Problem

    Dominik Neumayer Newbie

      Hi guys, I am new here and have some questions:

       

      I want to make historical data back to the current, so I have for each entity a dropDownBox where I list al revisions where you can select one and make it current.

      I've two classes. Patient 1---*  Untersuchung

       

      1.JPG

       

       

      1. can I do something like that or make hibernate envers do that ?

       

      2.JPG

       

       

      2.

      When I change data in the (One)Patient-Entity a new revisionnumber in Patient_AUD will be created.

      When I ADD or DELETE a (Many-Entity) Untersuchung, then in (One)Patient_AUD there also

      a new revisionno will be created - but when I CHANGE data in (Many)Untersuchung, NO

      new REVISIONENTRY in (One)Patient_AUD will be created.

       

      Is there a way to do it automatically, or do I have to make "dummy-changes" in (One)

      Patient during a change of the (Many) Untersuchung to keep it current.?

       

      Thx, Dominik

        • 1. Re: Envers Set merge / ManyToOne Cascade Update Problem
          Adam Warski Master

          1. No, there is currently no way like that to link back to historical entities. You will have to keep the revision number I guess and read it on-demand.

          2. That's correct, as the Patient entity isn't changed (whether Patient is changed when you add/remove an Untersuchung is discussable and configurable. No way to automatically change the Patient, as there's no way to know which entities are in the same graph.

           

          Adam

          • 2. Re: Envers Set merge / ManyToOne Cascade Update Problem
            Dominik Neumayer Newbie

            Ok, thank you for securing my assumption.

            @1: due to the incomparability of revisionEntity and currentEntity (entityManager.contains(revisionEntity and vice versa) always returns false, even it's the same entity)

            so I put both on Hashtables (with objectId as id) to compare it and create a delete- and a mergePersistList, which I have to

            remove/merge manually.

             

            @2: So, I will create a "dirty" solution and add or delete a blank of a text-column in the (One) Patient during the update of (Many) Untersuchung

            to keep it current.

             

            Thank you Adam for doing such great work here!