File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Composite key of foreign keys in M:M table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Composite key of foreign keys in M:M table" Watch "Composite key of foreign keys in M:M table" New topic
Author

Composite key of foreign keys in M:M table

Luigi Smith
Ranch Hand

Joined: Nov 08, 2003
Posts: 54
I am trying to use the O/R mapper tool in WSAD 5.1 to generate ejbs for several tables. I have a M:M relationship between two tables that leverage a typical joiner table, but in this joiner table I have a column for additional information about the relationship. If it wasn't for the latter, I usually just create a M:M relationship between two ejbs, but in this case, I need to implement the joiner table in ejb because I need to store this additional column.

The problem is I have the joiner table with two foreign keys (one each for the participating joined tables) that together represent a composite primary key (per a key constraint), and the O/R mapper tool complains that I don't have a primary key for this joiner table. Does anyone know how I can overcome this issue without creating an artificial key in this table? I am using DB2 8.1.

TIA!


Luigi<br />------------<br />Sun Certified Java Programmer<br />IBM Certified Enterprise Developer WSAD 5.0
Luigi Smith
Ranch Hand

Joined: Nov 08, 2003
Posts: 54
Silly rabbit...it helps to refresh the db schema in WSAD once you create the composite key (of the 2 FKs) in DB2. Lessons learned: Always create the composite key before attempting to gen EJBs.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Composite key of foreign keys in M:M table