-->
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: Problem with setMaxResult
PostPosted: Fri Jul 14, 2006 5:13 am 
Beginner
Beginner

Joined: Mon Mar 14, 2005 9:07 am
Posts: 27
Hi,

I am using Hibernate version:3.0 and I have made a small function in a standalone application to retrieve only some elements from the List in the following manner

Code:
   public List getAllCustomers() {
      List customerList = null;

      getHibernateTemplate().setMaxResults(50);
      customerList = getHibernateTemplate().find("from Customer c where c.password=?", "password");
      System.out.println("No. of customers retrieved=" + customerList.size());

      return customerList;
   }


and it is working absolutely fine and returns only 50 records out of 1000 in the database.

But when I am using the same function in another application that I am maintaining it returns me all the 1000 records. although setMaxResult has 50 as the parameter. Could you please tell me if maxResult() could be getting overridden by some configuration in the hibernate-properties or some other file.


In case you need any other information please let me know.
Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 18, 2006 9:15 am 
Beginner
Beginner

Joined: Mon Mar 14, 2005 9:07 am
Posts: 27
Hi all

I found the solution. Actually each time I was instantiating a new instance of HibernateTemplate. Since each time a new instance was being returned the setMaxResult changes to the old instance of HibernateTemplate were getting lost.


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