1 Reply Latest reply on Jun 11, 2008 3:51 PM by Herman Post

    Using ManyToMany Relationship

    Abhimanyu Singh Newbie

      Hi Everyone,

      I am using ManyToMany bidirectional relationship, fragment of code is given below for help:

      In One Entity i am coding as:

      @ManyToMany(cascade=CascadeType.REFRESH, fetch=FetchType.EAGER)
      @JoinTable(name="trd_t_sess_nommem",joinColumns = @JoinColumn(name="trs_trnsessnid_n_fk"),inverseJoinColumns = @JoinColumn(name="tnm_nommemid_n_fk"))
      public Set getNominatedmembersentity(){
      return nominatedmembersentity;
      }
      /**
      * @param nominatedmembersentity the nominatedmembersentity to set
      */
      public void setNominatedmembersentity(
      Set nominatedmembersentity) {
      this.nominatedmembersentity = nominatedmembersentity;
      }

      At other entity i am coding as given below:


      @ManyToMany(mappedBy="nominatedmembersentity")
      public List getTrainingsessionentity() {
      return trainingsessionentity;
      }


      But at the built time i am receiving the following error:


      --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
      ObjectName: persistence.units:ear=training.ear,jar=training.jar,unitName=intro
      State: FAILED
      Reason: javax.persistence.PersistenceException: org.hibernate.HibernateException: cannot simultaneously fetch multiple bags
      I Depend On:
      jboss.jca:service=DataSourceBinding,name=PostgresDS