[jboss-user] [JBoss Seam] - ManyToOne relationship

odupont do-not-reply at jboss.com
Mon Jul 23 08:50:09 EDT 2007


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?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4066633#4066633

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4066633



More information about the jboss-user mailing list