-->
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.  [ 3 posts ] 
Author Message
 Post subject: composite-id columns cannot be used in where clauses?
PostPosted: Wed Jun 17, 2009 6:37 pm 
Beginner
Beginner

Joined: Mon Sep 27, 2004 4:28 pm
Posts: 44
I'm working on a new project, and it's the first time I've needed to deal with a legacy database in hibernate. We have a composite key that includes two columns.. like so:

<composite-id>
<key-property name="id" column="id"/>
<key-property name="siteId" column="site_id"/>
</composite-id>

Problem is... this HQL query doesn't work: "from MyEntity where siteId=?"

Hibernate complains that it can't resolve the siteId property of MyEntity. I can't find this limitation called out in the documentation though. Is there a way to expose the properties used for composite-id as columns that can be searched on in HQL? I can't think of a good reason for this limitation, so I'm stumped.

Anyone know more about this?

Thanks in advance,
Phill


Top
 Profile  
 
 Post subject: Re: composite-id columns cannot be used in where clauses?
PostPosted: Thu Jun 18, 2009 11:44 am 
Beginner
Beginner

Joined: Mon Sep 27, 2004 4:28 pm
Posts: 44
Err. Not true. Typo on my part. For the record, properties in your composite id can certainly be included in your queries.


Top
 Profile  
 
 Post subject: Re: composite-id columns cannot be used in where clauses?
PostPosted: Thu Jun 18, 2009 11:51 am 
Newbie

Joined: Thu Jun 18, 2009 11:23 am
Posts: 2
You should refer it Like entity.siteId = ? where entity is the property refering to the object of composite key... Let me know if it helps


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.