2 Replies Latest reply on Jul 24, 2007 8:07 AM by odupont

    ManyToOne relationship

    odupont

      I want to create a ManyToOne relationship but I always receive an error from the import.sql.

      I have one entity Application which is linked to a Category.
      Application:
      @Entity
      @Table(name="APPLICATION")
      public class Application
      implements Serializable
      ...
      Category category;
      @ManyToOne(fetch = FetchType.LAZY)
      @JoinColumn(name="CATEGORY_ID")
      public Category getCategory() {
      return category;
      }
      public void setCategory(Category category) {
      this.category = category;
      }
      }

      Category:
      @Entity
      public class Category implements Serializable {
      ...
      @Id @GeneratedValue
      public Long getId() {
      return id;
      }

      public void setId(Long id) {
      this.id = id;
      }
      }

      import.sql:
      delete from APPLICATION
      delete from CATEGORY
      insert into CATEGORY (ID,NAME) values (1, 'CATEGORY 1')
      insert into CATEGORY (ID,NAME) values (2, 'CATEGORY 2')
      insert into APPLICATION (ID, CODE, NAME, DESCRIPTION, CATEGORY_ID) values (1, 'AP1', 'Application1', 'Test application which is represent the first application', 1)
      insert into APPLICATION (ID, CODE, NAME, DESCRIPTION, CATEGORY_ID) values (2, 'AP2', 'Application2', 'Test application which is represent the second application', 2)


      I received an error:
      SQLException Column not found: CATEGORY_ID statement...

      Can you help me?