-->
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: one-to-many with where clause?
PostPosted: Tue Aug 03, 2004 6:29 pm 
Newbie

Joined: Mon Jul 12, 2004 7:31 pm
Posts: 3
I am using hibernate 2.1 with oracle 8i.

I cant yet post the mapping documents because this is a design issue.

I have Table A & Table B.
Table B can contain 1 or more rows per row in Table A (FK/PK association)

I would like to fetch the list of all rows in A as ObjA that match a certain criteria (This was easy to do with the criteria API).

But I also want for EACH ObjA from the set of associated ObjBs I want to fetch ONLY the ObjB that has the max primary key. PrimaryKeys of type long are generated from a sequence.

I saw that there was a where clause on the one-to-many mapping & I was hoping I could use this to restrict the set of B's associated with each A to the one with max primaryKey using a where clause. This leads me to 2 issues:

(a) is it possible for the where clause on the one-to-many mapping to use the properties of A? if so does this follow the standard HQL syntax? (I think I saw a post that said this might not be possible...)

(b) if (a) is not possible are there any work around that anyone knows of?

Thanks
Pratima


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.