-->
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: Using Criteria search on last element of collection
PostPosted: Sun May 11, 2008 2:20 pm 
Newbie

Joined: Wed Apr 30, 2008 12:10 pm
Posts: 6
Hi!

Is it possible to add a restriction using a Criteria search on the last element of a collection? e.g. I have a Bike and it has multiple prices (Price being a composite -> Price.value, Price.category etc)and I want to restrict my search to the last element of prices.

criteria.createAlias("prices","pr").add(Restrictions.eq("pr.category", 2));

Would match any Bike that has a price category of 2 (even when the collection of prices would be [2 1 0]).

I want to replace hibSession.createQuery("from Bike bike where bike.prices[bike.prices.maxIndex].category = 0")


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.