0 Replies Latest reply on May 2, 2007 4:29 PM by Konstantin Kauz

    Fetch

    Konstantin Kauz Novice

      How can i make a fetch of collections for follow case:

      A(ManyToOne * ) -> (OneToMany 1 ) B (OneToMany 1)-> C (ManyToOne * ) C

      A(ManyToOne * ) ->C(ManyToOne 1)


      I need to iterate above A with A.B and need to contains C Collections.

      @Name("A")
      @Table(name="A")
      @Entity
      public class A implements Serializable{
      
       @Id @GeneratedValue
       private Long id;
      
       @ManyToOne
       @JoinColumn(name="b_id")
       private B b;
      
       @ManyToOne
       @JoinColumn(name="cl_id")
       private C c;






      @Entity
      @Name("B")
      @Table(name="B")
      public class B implements Serializable{
       @Id @GeneratedValue(strategy=GenerationType.AUTO)
       private int id;
       @NotNull
       private String bezeichnung;
      
       @OneToMany(mappedBy="b",cascade=CascadeType.ALL, fetch=FetchType.LAZY)
       @OrderBy("bezeichnung")
       private List<C> c;
      
       @OneToMany(mappedBy="b",cascade=CascadeType.ALL, fetch=FetchType.LAZY)
       @OrderBy("kennzeichen")
       private Set<A> a;





      @Entity
      @Name("C")
      @Table(name="C")
      public class C implements Serializable {
      @Id @GeneratedValue(strategy=GenerationType.AUTO)
      private long id;
      @NotNull
      private String bezeichnung;

      @ManyToOne
      @JoinColumn(name="b_id")
      private B b;

      @OneToMany(mappedBy="c",cascade=CascadeType.ALL, fetch=FetchType.EAGER)
      private Set A = new HashSet();


      i need to iterate above A that contains B and have to contains List of C.
      How can i do that?