3 Replies Latest reply on Jun 12, 2012 3:56 PM by adamw

    @OneToMany not returning the list

    brunosetra

      Hi,

       

      I'm new in envers and faced with a problem returning the Details list of a (many side) Master in a revision.

       

      My domain classes:

       

      {code}@Entity

      @Audited

      public class Master implements Serializable {

       

          @Id

          @GeneratedValue(strategy = GenerationType.IDENTITY)

          @Column(name = "masterId", nullable = false)

          private Long id;

       

          @OneToMany(targetEntity = Detail.class, cascade = CascadeType.ALL, fetch = FetchType.EAGER)

          @JoinColumn(name = "masterId", referencedColumnName = "masterId")

          private List<Detail> detail;

       

      }

       

       

      @Entity

      @Audited

      public class Detail implements Serializable {

       

          @Id

          private DetailCompoundKey compoundKey;

       

      }

       

      @Embeddable

      public class DetailCompoundKey implements Serializable {

       

          /**

           *

           */

          private static final long serialVersionUID = 9203958554519341517L;

       

          @Column(name = "masterId", nullable = false)

          private Long id;

       

          @Enumerated(EnumType.STRING)

          @Column(name = "type", nullable = false)

          private Type Type;

      }{code}

       

       

      {code}AuditReader reader = AuditReaderFactory.get(entityManager);

      List<Number> revisions = reader.getRevisions(Master.class, primaryKey);

      for (Number revision : revisions) {

          Master m = reader.find(entity, primaryKey, revision);

          m.getDetail(); // return an empty list

      }{code}