-
1. Re: How to write @ManyToMany if join table has third attribu
gus888 Mar 7, 2006 9:44 AM (in response to gus888)Hi all,
Sorry for my question is unclear. My question is: if join table has extra attributes besides the two foreign key (shown above), how to map its @ManyToMany code in entity bean. Thank you very much in advance. -
2. Re: How to write @ManyToMany/@JoinTable if join table has th
gus888 Mar 8, 2006 11:23 AM (in response to gus888)Hi all,
I found a little idea in the Hibernate in Action book, it is on the section of Using a collection of components for a many-to-many association in Chapter 6. It seems that I need to create a new class for the joint table. Any further suggestion is appreciated.
GUS -
3. Re: How to write @ManyToMany/@JoinTable if join table has th
chrismalan May 10, 2006 10:50 AM (in response to gus888)Hi Gus,
I see you posted in March. You may never see this response.
Yes, you have to explicitly create another @Entity bean, say MembershipDetails
Besides that, create a bean with an @Embeddable annotation as a composite primary key@Embeddable public class PartyMemberPK implements Serializable{ private String member_id, party_id; public PartyMemberPK(){} public PartyMemeberPK(String member_id, String party_id){ use your getters and setters to set these } }
Then use PartyMemberPK as a composite PK in MembersipDetails and add the date you want, as well.
Hope this helps. -
4. Re: How to write @ManyToMany/@JoinTable if join table has th
mazz May 10, 2006 10:57 AM (in response to gus888)I've given up using @ManyToMany. I started out with them and they work fine, but I always ended up needing to put in extra attributes thus running into this problem.
Now, even for my many-to-many relationships, I start out with @ManyToOne/@OneToMany with an explicity @Entity for the association table in the middle.