-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: @OneToOne cannot fetch multiple bags
PostPosted: Tue Aug 21, 2007 2:30 pm 
Newbie

Joined: Tue Aug 14, 2007 3:16 pm
Posts: 4
Code:

public class A implements Serializable{
   protected int aId;
   protected List<BInfo> bs = new ArrayList<BInfo>();
   protected C c;
   
   public User(){
      // Do nothing;
   }
   @Id
   @GeneratedValue
   @Column(name="pk_a_id")
   public int getAId() {
      return aId;
   }
   public void setAId(int aId) {
      this.aId = aId;
   }
   
   @OneToOne(mappedBy = "a")
   public C getC() {
      return c;
   }
   public void setC(C c) {
      this.c = c;
   }
   
   @OneToMany(cascade = CascadeType.ALL, fetch=FetchType.EAGER)
    @Cascade({org.hibernate.annotations.CascadeType.DELETE_ORPHAN})
   @JoinColumn (name="fk_a_id")
   public List<BInfo> getBs() {
      return bs;
   }
   public void setBs(List<BInfo> bs) {
      this.bs = bs;
   }
}

public class C implements Serializable{
   private int cId;
   private A a;
   
   private List<CGroup> CGroups = new ArrayList<CGroup>();
   
   @Id
   @GeneratedValue
   @Column(name="pk_c_id")
   public int getCId() {
      return cId;
   }
   public void setCId(int cId) {
      this.cId = cId;
   }
   
   @OneToMany(fetch=FetchType.EAGER)
   @JoinTable(
            name="Csgroups",
            joinColumns = { @JoinColumn( name="fk_c_id") },
            inverseJoinColumns = @JoinColumn( name="fk_c_group_id")
    )
   public List<CGroup> getCGroups() {
      return CGroups;
   }
   public void setCGroups(List<CGroup> cGroups) {
      this.cGroups = cGroups;
   }
   
   @OneToOne
   @JoinColumn (name="fk_a_id")
   public User getA() {
      return a;
   }
   public void setA(A a) {
      this.a = a;
   }



So i am receiving a cannot simultaneously fetch multiple bags, hibernate exception. Through the @OneToOne there is one eager in A and One in B but I believe them to be needed. Any ideas on how to get this to work.

Thanks,

- Phil


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.