I'm trying to get a list or array of objects using a (partial) foreign key lookup and Hibernate.
Essentially there's a Composite Primary Key in the table 'Document' and a "partial" foreign-key in the table 'Page'. Given a Document object, I'd like to select all Page objects that share the same ID (ie. select * Page where Document.ID = Page.DocumentId).
Here's the general setup:
Code:
+------------------+ +-------------------+
| Document | | Page |
+------------------+ +-------------------+
| Id* (PK-1_1) | <----| DocumentId (FK) |
| Version (PK-1_2) | | |
+------------------+ | PageId (PK) |
+-------------------+
*Composite primary
key on Document
Is there a way to create an association mapping file to allow Hibernate to get this without performing a general SQL call? I'd like to do something like document.getPages() and get a Collection back. Pointing me to another post with the answer would be super helpful as well.
Thanks!