-->
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: search on element of key
PostPosted: Tue Oct 26, 2004 5:44 am 
Newbie

Joined: Mon Feb 02, 2004 4:18 pm
Posts: 16
I've mapped a table with a composite key to ensure that rows are unique, but I often need to search on only one element of the key. How is this possible in hibernate?

ie. I've got a display item and a priceIndex which makes each display price unique, but I need to search for all prices for each display, so I can't search by primary key.

The only other solution is to create an arbitary key, which I'm keen to avoid. How have other people gotten around this problem?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 26, 2004 6:22 am 
Newbie

Joined: Mon Feb 02, 2004 4:18 pm
Posts: 16
Ok, found out that you can search by doing this

If the key contains two elements called "display" and "index" and the key is called "id", you can search by using the . notation like this baseObject.id.display

so a query looks like this

find("from BaseObject object where object.id.display = ?", display, Hibernate.entity(Display.class).

Simple.


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.