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

    Referencing _AUD tables ID's as foreign keys to entities

    Adriano Saturno Newbie

      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!