1 Reply Latest reply on Aug 9, 2011 2:39 AM by adamw

    Referencing _AUD tables ID's as foreign keys to entities

    drsaturno

      Does it make sense?

       

      I´m thinking about using Enver as a tracer of "valid" entities.

       

      Let's explain:

       

      I have an persisted entity "Alpha", that could be valid or not for my business.

       

      There´s a java method that set Alpha as valid, let´s call it "Process"

       

      Any edition in Alpha after Process invalidates Alpha.

       

      My business doesn´t like invalids Alphas (who likes?...). It likes the last valid Alpha.

       

      OK, to solve this issue I will use Envers to show me the last valid Alpha (before this last edition and after this last Processing).

       

      But how? Maybe I could save the Alpha_AUD ID in an "AlphaGoodMemory" entity after Processing. The valid Alpha is this one, perfect! It could have a foreign key reference in AlphaGoodMemory to this Alpha_AUD ID.

       

      Can I? How to map a foreign key to  Alpha_AUD using a hibernate-mapping hbm?

       

      One more question: Can I use this  Alpha_AUD element as an Alpha entity with no cast (I guess not...)

       

      Thanks!

        • 1. Re: Referencing _AUD tables ID's as foreign keys to entities
          adamw

          Well, you could have a foregin key to the revision entity (which has a revision number corresponding to the good Alpha version). Having a foreign key directly to Alpha_AUD can be tricky.

           

          Anyway, I think that you are more looking for a workflow solution (I suppose you can have multi-level acceptance in the future)? Envers isn't really for workflows, just for auditing.

           

          Adam

          1 of 1 people found this helpful