Hi, Please forgive me if this is a really simple problem, but I have been working with hibernate (using annotations) on a side project, and am having problems with the many-to-many relationship being saved. What I would really like is when I save an Article, it saves its Categories (whether or not the category has already been persisted to the DB). Here is what I've got:
public class Author { .... @ManyToMany(fetch=FetchType.EAGER) @Cascade({CascadeType.ALL}) private List<Category> categories = new Vector<Category>(); }
When hibernate generates the database, I can see the Article_Category table created; however, when I call merge with an object loaded with either (I tried both) previously created categories or new categories, nothing gets inserted into this table for the relationship. Subsequently every time I re-run my test app, it doesn't find any of the categories on the articles it looks at. What am I doing wrong? I'm guessing its something really simple. Thanks for your help!
-Eric LeVin
|