3 Replies Latest reply on Jan 9, 2014 11:26 AM by Kent Gibson

    is join two entities in audit query possible?

    Tamilselvi Dhandapani Newbie

      Hi

       

      Am using Envers version : 3.6.3.Final

      I wanted to join two audit tables having a one to many relationship, with criteria's to be passed on both the tables.

       

      For eg: Event.java

       

      @OneToMany(mappedBy = "event", fetch = FetchType.LAZY, orphanRemoval = true)

          @Cascade(value = { CascadeType.ALL })

          private List<Agreement>     agreements          = new ArrayList<Agreement>();

       

       

      Agreement.java

       

      @ManyToOne(fetch = FetchType.LAZY)

          @JoinColumn(name = "ID_EVENT")

          private Event             event;

       

      i want to fetch the event by passing an ID and date of the event and also the status of the agreement.And the result should be the latest version on that date.

      How can i join these conditions in the audit query?

      Can i make all these conditions in a single query?

       

      My query is  :

      AuditQuery query = reader.createQuery().forRevisionsOfEntity(Event.java, false, true);

                 query.add(AuditEntity.id().eq(eventId));

                  query.add(AuditEntity.property("updatedDate").le(updatedDate));

                  query.add(AuditEntity.property("status").ne(Status.DELETE));

                  query.add(AuditEntity.property("agreements.status").eq(INVALID));

       

      I have changed here and there and tried but nothing worked.

       

      Please advice on this issue.

       

      Thanks in Advance,

      Swetha