|
Re: How can I associate primary and secondary tables with a join criteria other than the compound ke [message #628626 is a reply to message #624561] |
Thu, 23 September 2010 13:32 |
Chris Delahunt Messages: 1389 Registered: July 2009 |
Senior Member |
|
|
Hello,
I'm not sure I follow the table design here. Does columnA uniquely identify rows in both tables? If so, why use the compound pk fields and not just use the columnA as the Id? If it is not unique, it implies that Table2 has a 1:M relationship to rows in Table1. This will cause problems on inserts, as using a secondary table annotation relies on there being a 1:1 relationship - it will cause duplicate inserts to Table2 when a non-unique columnA is used.
If columnA is not unique, I would recommend mapping the second table as its own entity and using a 1:1 relationship from the first, allowing the entity to be shared. If it is unique, you can mark columnA as the primary key, or if you still wish to use a composite pk for the table, map the secondary table using native EclipseLInk api in a customizer using the descriptor addTable and addForeignKeyFieldNameForMultipleTable methods:
descriptor.addTable("TABLE2");
descriptor.descriptor.addForeignKeyFieldNameForMultipleTable ( "TABLE1.COLUMNA", "TABLE2.COLUMNA");
Best Regards,
Chris
|
|
|
Powered by
FUDForum. Page generated in 0.02988 seconds