-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Partial Foreign Key Lookup
PostPosted: Tue May 10, 2011 1:44 am 
Newbie

Joined: Tue May 10, 2011 1:12 am
Posts: 1
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!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.