-->
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: setFirstResult returning empty list before the end of data
PostPosted: Fri Jun 05, 2009 2:39 pm 
Newbie

Joined: Fri Jun 05, 2009 2:26 pm
Posts: 2
Hello and I apologize if this has already been covered. I made numerous Google searches and also searched the forum here before posting. I am using the Criteria objects setFirstResult and setMaxResults methods to implement paging in my web application. I have about 167 records that I am paging through in the database. I display 15 records at a time. Everything works alright until about page 10. At page 11 (firstIndex = 150) I get an empty list. On the last page, page 12, same thing. Empty list.

So, for some reason everything works great until page 10 but then it stops working. I am connecting to an Oracle 10g database. Anyone have any ideas?

Thanks in advance for the help. Here is the code:

Order order = null;

if(sortAscending) {
order = Order.asc(sortColumn);
} else {
order = Order.desc(sortColumn);
}

Criteria cr = getSession().createCriteria(DataAssetCatalog.class)
.setFirstResult(firstIndex)
.setMaxResults(numRecords)
.createAlias("pointOfContact", "poc")
.createAlias("submitter", "sub")
.addOrder(order);

return (List<DataAssetCatalog>)cr.list();


--Kamran


Top
 Profile  
 
 Post subject: Re: setFirstResult returning empty list before the end of data
PostPosted: Mon Jun 08, 2009 2:44 pm 
Newbie

Joined: Fri Jun 05, 2009 2:26 pm
Posts: 2
Ok, so I found my problem so I retract my question. Apparently the problem came from bad data. Well, to me it's bad data, but whatever. I had set a couple of properties on my table to be fetched eagerly. This of course results in a join. The problem was that some of these records had nulls for the properties I was trying to join on. This caused the join to not work and the record was not returned so I was getting fewer records than I should. I fixed this by complaining about the bad data, fixing these records to not be null for these columns. The other fix, of course, could be to use an outer join.

Weird symptoms. Anyway, it's fixed now.. :)

--Krullshards


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.