2 Replies Latest reply on Mar 12, 2007 6:58 AM by Martin Polet

    @manytoone left join problem

    Eduard Newbie

      Hi everyone,

      I have many-to-one unidirectional relationship between two objects as follows:

      @Entity
      @Table(name = "A")
      public class A implements Serializable {
      
       private Long id;
      
       private B bObject;
      
       @Id
       public Long getId() {
       return id;
       }
      
       public void setId(Long _id) {
       id = _id;
       }
      
       @ManyToOne
       @JoinColumn(name = "a_id", insertable = false, updatable = false, nullable = true)
       public B getBObject() {
       return bObject;
       }
      
       public void setBObject(B _bObject) {
       bObject = _bObject;
       }
      }
      
      @Entity
      @Table(name = "B")
      public class B implements Serializable {
      
       private Long id;
      
       private Long aId;
      
       @Id
       public Long getId() {
       return id;
       }
      
       public void setId(Long _id) {
       id = _id;
       }
      
       @Column(name="a_id")
       public Long getAId() {
       return id;
       }
      
       public void setAId(Long _aId) {
       aId = _aId;
       }
      }
      


      in the session bean I am getting List as follows:

      ...
      Query query = em.createQuery("select a from A a left outer join a.bObject as b ");
       query.setFirstResult(start);
       query.setMaxResults(MSG_PER_PAGE);
       List<A> result =query.getResultList();
      ...
      


      The problem is that every time there is no record in table B that corresponds to record in table A I am getting the javax.persistence.EntityNotFoundException: Unable to find B with id 123

      I am running Jboss 4.0.4.

      Any help is appreciated.

      Ed

        • 1. Re: @manytoone left join problem
          Florian Schweizer Newbie

          I have the same problem.

          • 2. Re: @manytoone left join problem
            Martin Polet Newbie

            HI,

            I have also the same error and I don't know where the problem is...
            I am using netbeans 5.5 and i tried under jboss 4.0.4 and 4.0.5, the problem is always the same:

            10:51:26,783 WARN [ServiceController] Problem starting service persistence.units:ear=EAW1.ear,jar=EAW1-ejb.jar,unitName=EAW1-ejbPU
            javax.naming.NameNotFoundException: mysql-EAW not bound

            --- MBeans waiting for other MBeans ---
            ObjectName: persistence.units:ear=EAW1.ear,jar=EAW1-ejb.jar,unitName=EAW1-ejbPU
            State: FAILED
            Reason: javax.naming.NameNotFoundException: mysql-EAW not bound
            I Depend On:
            jboss.jca:service=ManagedConnectionFactory,name=mysql-EAW


            The mysql-EAW is the name I gave to the data source when creating the persistence unit in netbeans 5.5.

            see here: http://imacx.ath.cx/img/eaw-mysql.jpg

            Thx for helping me