Skip to main content

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

Well, I'll refrain from offering the obvious solution - create your
own table - obviously you want DML generation, an area where I haven't
ventured much.

Anyway, on to your second question. Implementing indexed lists. What
do you mean implementing indexed lists on top of JPA?

java.util.List is already indexed..so I don't really follow your question.


./tch



On Sat, Nov 29, 2008 at 12:51 PM, cowwoc <cowwoc@xxxxxxxxxxxxxxxx> wrote:
>
> 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.
>
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>


Back to the top