10 Replies Latest reply on Feb 1, 2012 2:16 AM by Adam Warski

    Bidirectional associations and hierarchies

    Hernán Chanfreau Master

      Hi!

       

      I came upon this situation: Suppose a simple class hierarchy where A is the superclass and A1 and A2 are subclass of A (A1 and A2 are "sisters").

       

      There is another class B which has a collection of A1 instances and different a collection of A2 instances. Super class A has the bidirectional relation to B.

       

      The mapping in B is one-to-many for both collections with invers=true.

      The mapping in A is many-to-one for the inverse side.

       

      When envers tries to find the mappedBy property (which is defined in A) inside A1 or A2, fails because there is no property indicated by "mappedBy". It´s because the mappedBy attribute is defined in the superclass A.

       

      I found that in CollectionMetadataGenerator.getMappedBy(Collection collectionValue) envers looks for mappedBy only in the referenced class and no on its superclasses. I added the code for searching on superclasses if the referenced class hasn´t the attribute and worked fine.

       

      What do you think about? It´s expected to work only with the referenced class info or we need to inspect superclasess as well ?

       

      I´m attaching a test case.

       

      Regards. Hernán.