I have a SITE, and a SHIPTYPE table. These two table have a many-to-may 
relationship (the cross reference table is SHIPTYPE_X_SITE). I created the 
corresponding entities Site and ShipType. For the creation of ShipType, my UI 
has ShipType related fields as well as a list of sites. Therefore,ShipType has 
a collection of Sites:

        @ManyToMany(fetch=FetchType.LAZY)
        @JoinTable(name="SHIPTYPE_X_SITE",
                        [EMAIL 
PROTECTED](name="SHIP_TYPE_CD",referencedColumnName="SHIP_TYP_CD")},
                        [EMAIL 
PROTECTED](name="ST_SITE_ID",referencedColumnName="SITE_ID")})
        private List sites;

and the cross reference records are saved when I save ShipType. That is good.

On the other side, the creation of Site just have some basic Site related 
fields. There is no list of ShipTYPES in the UI. 

However, I do have the need to retrieve list of ShipTypes associated with a 
site sometimes. So I added following association to Site entity bean:

        @ManyToMany(fetch=FetchType.LAZY)
        @JoinTable(name="SHIPTYPE_X_SITE",
                        [EMAIL 
PROTECTED](name="ST_SITE_ID",referencedColumnName="SITE_ID")},
                        [EMAIL 
PROTECTED](name="SHIP_TYPE_CD",referencedColumnName="SHIP_TYP_CD")})
        private List shipTypes; 

Once I did that, if I modify  Site and save (collection shipTypes is null), all 
the cross reference records are gone for the given site. My question is how can 
I make the Site bean has the association, but not doing the cascading? Thank 
you very much for you help.

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4177530#4177530

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4177530
_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to