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

    @ManyToOne reference

    aminmc

      Hi

       

      I have the following object model:

       

       

      class A {

       

      @Id

         Long id

         String objectId;

       

      @OneToMany

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

       

      ... Getters and setters...

       

      }

       

      @Audited

      class B {

        @Id

         Long id;

       

        String name;

         String value;

       

        @ManyToOne

         @JoinColumn(name="A_REF")

         @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.

       

      THanks

        • 1. @ManyToOne reference
          adamw

          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 ...

           

          Adam