-->
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.  [ 7 posts ] 
Author Message
 Post subject: setFirstResult on multiple tables
PostPosted: Wed Nov 24, 2004 3:55 am 
Newbie

Joined: Sun Aug 29, 2004 11:45 am
Posts: 16
Hi,
I have test the following on Hibernate version: 2.1.7 and preior and got the same results.

When I use setFirstResults on a query like this:

Query query =
session.createSQLQuery("select {table.*} from TABLE {table}");

query = query.setFirstResults(lastOffset + pageSize);

List l = query.list();

Then it is OK and each time the list contains the next required records.

But when I am trying to select from more then one table (either by join or not) like this:


Query query =
session.createSQLQuery("select {table_a.*}, {table_b.*} from TABLE_A {table_a}, TABLE_B {table_b} where table_a.field = table_b.field");

query = query.setFirstResults(lastOffset + pageSize);

List l = query.list();

Then I always get the same first results like the cursor begins always from position 0 (Althogh I can see that SQLQueryImpl holds the firstResults value that I gave it.

Is there a way to bypass that behavior?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 24, 2004 4:08 am 
Regular
Regular

Joined: Tue Jan 27, 2004 12:22 pm
Posts: 103
I'll quess that you batch size of retrieving the records is larger or as large as your resultset.
Try to use .setMaxResults(maxPerPage)[/b] on your query and make sure maxPerPage is less then your resultset size.

_________________
Dencel
- The sun has never seen a shadow -


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 24, 2004 4:12 am 
Newbie

Joined: Sun Aug 29, 2004 11:45 am
Posts: 16
Hi,

I didn;t mantioned it before because I have found in my tests that it is irrelevant but I did use setMaxResults and maxPerPage is way less then what the table is containing.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 24, 2004 4:14 am 
Regular
Regular

Joined: Tue Jan 27, 2004 12:22 pm
Posts: 103
amichay2 wrote:

is way less then what the table is containing.


Is it less then what the query is containing?

_________________
Dencel
- The sun has never seen a shadow -


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 24, 2004 4:17 am 
Newbie

Joined: Sun Aug 29, 2004 11:45 am
Posts: 16
Yes sure, sorry for not making it clear...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 24, 2004 4:30 am 
Regular
Regular

Joined: Tue Jan 27, 2004 12:22 pm
Posts: 103
Show your configuration and mapping. I don't see why this shouldn't work. Maybe somebody else has an idea on this?

_________________
Dencel
- The sun has never seen a shadow -


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 24, 2004 6:24 am 
Newbie

Joined: Sun Aug 29, 2004 11:45 am
Posts: 16
Hi,

Please, if you are familer with the related problem reply to that message I need help about it.


I have test the following on Hibernate version: 2.1.7 and preior and got the same results.

When I use setFirstResults on a query like this:

Query query =
session.createSQLQuery("select {table.*} from TABLE {table}");

query = query.setFirstResults(lastOffset + pageSize);

List l = query.list();

Then it is OK and each time the list contains the next required records.

But when I am trying to select from more then one table (either by join or not) like this:


Query query =
session.createSQLQuery("select {table_a.*}, {table_b.*} from TABLE_A {table_a}, TABLE_B {table_b} where table_a.field = table_b.field");

query = query.setFirstResults(lastOffset + pageSize);

List l = query.list();

Then I always get the same first results like the cursor begins always from position 0 (Althogh I can see that SQLQueryImpl holds the firstResults value that I gave it.

Is there a way to bypass that behavior?


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