users@glassfish.java.net

Re: JPA Toplink ManyToMany Persistence Problem

From: <glassfish_at_javadesktop.org>
Date: Fri, 09 Apr 2010 11:39:42 PDT

Hi mmxbass,

In Chapter.java change for this:

@ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE },
                mappedBy = "chapterCollection",
                targetEntity = Strand.class)
private Collection<Strand> strandCollection;


In Strand.java chage for this:

@ManyToMany(fetch = FetchType.EAGER, targetEntity = Chapter.class,
                        cascade = { CascadeType.REMOVE, CascadeType.MERGE,
                                                CascadeType.REFRESH })
@JoinTable(name = "chapter_in_strand",
                   joinColumns = { @JoinColumn(name = "strand", referencedColumnName = "id") },
                   inverseJoinColumns = { @JoinColumn(name = "chapter", referencedColumnName = "id") })
private Collection<Chapter> chapterCollection;


I hope it help you!
Regards
[Message sent by forum member 'cleitonls']

http://forums.java.net/jive/thread.jspa?messageID=396143