-->
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.  [ 4 posts ] 
Author Message
 Post subject: how to access results of criteria query with projections?
PostPosted: Wed Jul 13, 2005 1:32 pm 
Newbie

Joined: Tue Jul 12, 2005 6:55 pm
Posts: 9
I have something like this:
Code:
    Criteria finalCriteria = this.getSession().createCriteria(AbstractBook.class);
    finalCriteria.setProjection(Projections.projectionList().add(Projections.rowCount()));
    finalCriteria.add(Restrictions.like("title","%some"));
    List result = finalCriteria.list();


where can I find description how to access that result list? What kind of objects are stored threre?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 13, 2005 2:01 pm 
Regular
Regular

Joined: Thu May 26, 2005 2:08 pm
Posts: 99
You can easily find this info by running your code in a debugger.

Make sure you try it with multiple projections as well, because the result will be different than what you'd get with only one projection.


Top
 Profile  
 
 Post subject: gonna be difficult...
PostPosted: Wed Jul 13, 2005 7:34 pm 
Newbie

Joined: Tue Jul 12, 2005 6:55 pm
Posts: 9
gonna be difficult - hibernate code is executed by spring framework within EJB container of JBoss - hard to debug outside container...


Top
 Profile  
 
 Post subject: Integer with singleResult
PostPosted: Wed Jul 13, 2005 7:59 pm 
Senior
Senior

Joined: Wed Jul 13, 2005 4:31 pm
Posts: 142
Location: Seattle, WA
For this case, this might be better...

Integer count = (Integer) finalCriteria.uniqueResult();

If you want to use list, I think it returns a list with 0th item as integer containing count.


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