Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] @ManyToMany relationship for a List?

Hi,

A playlist contains multiple music clips. And each clip may be associated
with multiple playlists. I believe this should be mapped as follows:

class Playlist
{
  @ManyToMany
  @JoinTable(name="playlist_to_clip")
  List<Clip> getClips();
}

Unfortunately I can't get this to work. EclipseLink generates a
"playlist_to_clip" table with two columns: playlist and clip. The primary
key is the pair [playlist, clip]. In other words, it is impossible for a
Playlist to contain the same Clip multiple times (which is desirable).

I find the mapping that EclipseLink generates confusing because it seems to
only make sense for Sets, not Collection or List (I've tried both). If was
mapping this by hand I'd add an "id" primary key column to the join table
and allow duplicate [playlist, clip] combinations. Any ideas on how to
implement this in EclipseLink?

Going one step further, are there existing (unofficial) libraries for
implementing indexed lists on top of JPA or will I have to write this from
scratch?

Thank you,
Gili
-- 
View this message in context: http://www.nabble.com/%40ManyToMany-relationship-for-a-List--tp20749567p20749567.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top