-->
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: Criteria to fetch entity's set size
PostPosted: Thu Aug 07, 2008 4:40 pm 
Newbie

Joined: Thu Aug 07, 2008 4:35 pm
Posts: 9
my entity object contains a set. Normally if i want the number of elements i would call the size() function.

How do i impliment this with criteria? this will be used for ordering the results. I can cheat and create a counter, and do the order by that column name desc...
but i bet there is a "nicer" way of doing this.

Thanks

P.S. if the nicer way is creating an Example object, as long as it worked w/out modifying the entity i will be pleased :)

Thanks,


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 17, 2008 7:24 pm 
Newbie

Joined: Thu Aug 07, 2008 4:35 pm
Posts: 9
So i found on the net something along the lines of the following. Unfortunately this did not work.

Code:
ENTITY
private Set<MyEntity> myList = new HashSet<MyEntity>();

SEARCH
criteria.setFetchMode("myList", FetchMode.JOIN);
criteria.addOrder(Order.desc("myList"));


Anyone have any ideas?


Last edited by m2m on Sun Aug 17, 2008 8:11 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 17, 2008 7:26 pm 
Newbie

Joined: Thu Aug 07, 2008 4:35 pm
Posts: 9
sorry double post


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.