1 Reply Latest reply on Mar 30, 2011 12:29 PM by Adam Warski

    @ManyToOne reference

    Amin MC Newbie



      I have the following object model:



      class A {



         Long id

         String objectId;



        Set<B> data = new HashSet<B>();


      ... Getters and setters...





      class B {


         Long id;


        String name;

         String value;




         @Audited (targetAuditMode=..NOT_AUDITED)

        A belongsTo

        ... Getters and setters ...




      I have  a method signature which takes a objectId, name and asOf date.  I was wondering whether it would be possible to execute a query that would return me a version of B based on the objectId which belongs to A.  I looked at doing something like AuditEntity.relatedId("belongsTo").eq(belongsTo.getId()) which works but I need to first fined A's PK by executing a query to find A based on objectId.  Is there a way to do this using the envers query (somekind of join)?


      Any help would be appreciated.



        • 1. @ManyToOne reference
          Adam Warski Master

          Unfortunately that won't be possible - even if Envers supported joins, that would be only between audit entities. The B_AUD and A entities aren't even related from the Hibernate point of view, so HQL wouldn't permit a join between them ...