-->
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: Query iterate() not supporting setFirstResult() method...?
PostPosted: Thu Aug 19, 2010 5:29 am 
Newbie

Joined: Thu Sep 24, 2009 12:46 am
Posts: 10
Hi friends,

I tried below code.

In this, it is not honoring the firstResult() method for query.iterate().

But it is fetching data only based on maximum record property of query object.

Code:
Query query2 = session.createQuery("from Account as c where c.id = '2000'");
        query2.setCacheable(true);
        query2.setMaxResults(10);
        query2.setFirstResult(2);
        Iterator<Account> customerIterator2 = query2.iterate();
       
        while(customerIterator2.hasNext())
        {
            Account account = customerIterator2.next();
            System.out.println("Customer Id =" +  account.getId() + "Customer Name =" + account.getName());
        }

I am expecting that the query will return rowNum > 2 and rowNum < 10, so the total number of rows should be returned is 8.

but actually it is returning 10 rows.

I want only 8 rows not 10 rows, how this functionality i can achieve using hibernate.?


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.