-->
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.  [ 2 posts ] 
Author Message
 Post subject: Criteria Search based on only 1 key from a composite id?
PostPosted: Thu Nov 01, 2007 1:12 pm 
Newbie

Joined: Thu Nov 01, 2007 1:06 pm
Posts: 12
I need to search for an entity that has a composite key but only by one of its keys. How do I do this?

Here is my mapping:

<hibernate-mapping>
<class name="database.entity.Title" table="VTITLE">
<composite-id name="id" class="database.entity.TitleId">
<key-property name="ltbDistrictCd" type="string">
<column name="LTB_DISTRICT_CD" length="2"/>
</key-property>
<key-property name="titleNmbr" type="string">
<column name="TITLE_NMBR" length="11"/>
</key-property>
</composite-id>
<property name="dcmntDistrictCd" type="string">
<column name="DCMNT_DISTRICT_CD" length="2" not-null="true"/>
</property>

...
</hibernate-mapping>


I'm trying to do a search in the DB by only "titleNmbr". How do I do this when my "id" is in a separate class (TitleID)??

Regards!

-Jon


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 01, 2007 2:00 pm 
Newbie

Joined: Thu Nov 01, 2007 1:06 pm
Posts: 12
Nevermind I just figured it out. Easy.

To reference the column you want to restrict on you need to put in its fully qualified name.

In the case of mine it would be ...Restriction.eq("id.titleNmbr")...

:)


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