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

    Error while using  @JoinTable

    Mahesh Patil Newbie

      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