2 Replies Latest reply on Oct 3, 2005 7:31 AM by maheshp

    Error while using  @JoinTable

    maheshp

      Hello

      I am using jboss-EJB-3.0_RC2 , which is released on 19/09/2005. It contains Hibernate 3.1rc2,
      Hibernate_Annotation3.1beta5, Hibernate-EntityManager 3.1 beta3.

      I am trying to join two tables using @JoinTable annotation, while fetching the data i got
      the following error.

      17:37:54,576 WARN [JDBCExceptionReporter] SQL Error: 904, SQLState: 42000
      17:37:54,654 ERROR [JDBCExceptionReporter] ORA-00904: "EMPLOYEES1_"."EMPLOYEES_E
      MPID": invalid identifier

      17:37:54,701 INFO [DefaultLoadEventListener] Error performing load command
      org.hibernate.exception.SQLGrammarException: could not load an entity: [Dept#10]

      Here is the code:

      @Entity
      @Table(name="department")
      public class Dept {
      private int dept;
      private String name;

      private List employees;


      @OneToMany(fetch= FetchType.EAGER)
      @JoinTable ( table = @Table(name = "emp"),
      joinColumns = {@JoinColumn(name = "dept")}
      )
      public List getEmployees() {
      return employees;
      }
      public void setEmployees(List employees) {
      this.employees = employees;
      }


      @Id(generate = GeneratorType.NONE)
      public int getDept() {
      return dept;
      }
      public void setDept(int dept) {
      this.dept = dept;
      }

      @Column(name="name")
      public String getName() {
      return name;
      }
      public void setName(String name) {
      this.name = name;
      }


      }


      @Entity
      @Table(name="emp")
      public class Employee {
      private int empId;
      private String name;
      private int dept;
      private int manager;

      .........getters and setters

      }

      i am not getting why this error is comming?

      Thanks in advance

      Regards
      Mahesh

        • 1. Re: Error while using  @JoinTable
          epbernard

          You don't provide enough info. Try to reduce your problem in 2 minimal classes

          • 2. Re: Error while using  @JoinTable
            maheshp

            Hello

            Here is the info.

            I am using two tables emp and department and two entity beans
            for each of the table.
            I want to get the all the employees belonging to a department, using @JoinTable annotation. But i am getting above mentioned error.

            The above given code contains only two class.

            If you want more info, please specify what additional info you want.

            Thanks
            Mahesh