-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Problem Cascading Many-to-Many
PostPosted: Tue May 19, 2009 4:25 pm 
Newbie

Joined: Tue May 19, 2009 4:17 pm
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.