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

    @OneToMany not returning the list

    Bruno SeTra Newbie



      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:




      public class Master implements Serializable {



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







      public class Detail implements Serializable {



          private DetailCompoundKey compoundKey;





      public class DetailCompoundKey implements Serializable {





          private static final long serialVersionUID = 9203958554519341517L;


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

          private Long id;



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

          private Type Type;




      {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