[jboss-user] [Persistence,JBoss/CMP, Hibernate, Database] - Fetch

KoniKoni do-not-reply at jboss.com
Wed May 2 16:29:25 EDT 2007


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?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4042618#4042618

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4042618



More information about the jboss-user mailing list