[jboss-user] [EJB 3.0] - The problem of
bairaulinter
do-not-reply at jboss.com
Wed Dec 13 11:52:26 EST 2006
I have 3 entity beans, followings are the codes:
public class Product implements Serializable {
........
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "categoryID")
public Category getCategory() {
return category;
}
public void setCategory(Category cate) {
this.category = cate;
}
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "productOwner")
public User getUser() {
return user;
}
public void setUser(User u) {
this.user = u;
}
.......
}
=============================================
public class User implements Serializable{
.........
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
public Collection getProducts() {
return products;
}
public void setProducts(Collection pro) {
this.products = pro;
}
}
=============================================
public class Category implements Serializable {
..........
@OneToMany(mappedBy = "category", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@OrderBy(value = "productID ASC")
public Collection getProducts() {
return products;
}
public void setProducts(Collection pro) {
this.products = pro;
}
}
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Then, I want to insert a record into the database. First, the categoryID and userID have been in the database! categoryID and userID are the foreign key of table: Product!
I don't know how to do it! Can you help me?
Thank you!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3993469#3993469
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3993469
More information about the jboss-user
mailing list