-->
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.  [ 4 posts ] 
Author Message
 Post subject: Using Composite Identifiers in HQL Query?
PostPosted: Wed Mar 22, 2006 10:30 am 
Regular
Regular

Joined: Tue May 31, 2005 9:55 am
Posts: 67
Is it possible to use Composite Identifiers in an HQL query.

e.g.

I have 1-M relation to and entity with a composite identifier and I would like to join on that association like

join ra.Requirement r where ra in (:aliases);

SetParameterList("aliases", requirementAliases);

where Requirement is an entity with a Composite Identifier and
requirementAliases is a collection of those entities.

craig


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 22, 2006 6:17 pm 
Regular
Regular

Joined: Tue May 31, 2005 9:55 am
Posts: 67
Maybe I should rephrase my question.

Give an entity with a composite key, is it possible to select a group of those entities if I have a list of composite keys, something like

select * from EntityWithCompositeKey e where e.id in (:compositeKeys)

thanks,
craig


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 23, 2006 8:43 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
I believe it will work, there is code in NH to handle multiple-column expressions, but of course you should try for yourself.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 23, 2006 9:20 am 
Regular
Regular

Joined: Tue May 31, 2005 9:55 am
Posts: 67
Hello Sergey,

I did try it but was not able to get it to work. The error was something like 'expression cannot end with composite'. Basically I created an ArrayList of an instance of the Entity with just the Composite Key properties filled out and passed that to SetParameterList. Since I couldn't find any units tests that excercise a parameter list of composite keys I was'nt sure if it is supported.

thanks,
craig


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

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.