-->
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: How do I limit the number of items returned?
PostPosted: Sun Apr 08, 2012 3:11 pm 
Newbie

Joined: Thu Jan 19, 2012 1:21 pm
Posts: 12
I'm trying to return the top few items from my query, but I am still getting the whole list.
I'm trying to set the limit by using setMaxResults(max).

Can anyone point out what I am doing wrong in this query?
Thanks

Code:
                org.hibernate.Transaction tx = session.beginTransaction();
                Query q = session.createQuery( "from TbEventTrxn where biCustDeviceId="+custDeviceId+" and iEventTrxnTypeId="+txnTypeId+" and dtPostTime between :start and :end order by dtTranTime" );
                q.setMaxResults(max);
                q.setParameter( "start", startDate );
                q.setParameter( "end", endDate );
                list = (List<TbEventTrxn>)q.list();


Top
 Profile  
 
 Post subject: Re: How do I limit the number of items returned?
PostPosted: Tue Apr 10, 2012 9:06 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Which database, jdbc-driver and which hibernate dialect are you using?
Note that q.setMaxResults(max) is not supposed to work with all hibernate-dialects / jdbc-drivers


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.