users@glassfish.java.net

Re: JPA - A Complex Relationship Scenario. Help!!!

From: <glassfish_at_javadesktop.org>
Date: Tue, 21 Jul 2009 14:33:13 PDT

You can do it in different ways but the join table with composite key is probably the easiest. The join table contains {id_user, id_mentor, id_topic} where id_user and id_mentor are FKs to the PK in the user table and id_topic is FK to the topic table. The three columns combine to give the PK. I am assuming your design only has one table containing "users" and that a mentor is simply a user with a flag to identify they are a mentor. A different database structure will require a different solution.

Regardless - create the database first, then reverse engineer the JPA classes.
[Message sent by forum member 'ggierer' (ggierer)]

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