users@glassfish.java.net

Re: _at_ManyToMany Using Composite Key

From: <glassfish_at_javadesktop.org>
Date: Tue, 28 Aug 2007 14:06:03 PDT

Gordon:

   Thank you again for offering some very good suggestion.

   I went back and looked at the @ManyToMany relationship. I have it defined as follows:
   [code]

    Document.java
                @ManyToMany(cascade={CascadeType.ALL})
        @JoinTable(name="DOCUMENT_COLLECTION",
                        joinColumns=_at_JoinColumn(name="DC_DOCUMENT_ID", referencedColumnName="DOCUMENT_ID"),
                        inverseJoinColumns={_at_JoinColumn(name="DC_COLLECTION_ID", referencedColumnName="SITE_ID"),
                                                            @JoinColumn(name="DC_COLLECTION_ID", referencedColumnName="NAME"),
                                                            @JoinColumn(name="DC_COLLECTION_ID", referencedColumnName="GROUP_DATE")}
        )
public Set<Collection> getCollectionSet() {
                return collectionSet;
        }
   [/code]
  

[b]The only thing I can think about is the @JoinColumns statments... Here, I use the three fields from the CompositePK as it maps back to the DC_COLLECTION_ID[/b].

   Collection.java

   [code]
               @ManyToMany(mappedBy="collectionSet")
        public Set<Document> getDocumentSet() {
                return documentSet;
        }
   [/code]

I am seeing NO writes to the database other than the SEQUENCE Table.

You are correct about the Collection and Collection_Type mapping...... This was the reason why the SEQUENCE table was not getting updated. This is fixed.....as I stated in my earlier posts.
[Message sent by forum member 'russ_ray' (russ_ray)]

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