-->
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: Pagination
PostPosted: Mon Jul 21, 2008 3:21 pm 
Newbie

Joined: Mon Apr 21, 2008 5:07 pm
Posts: 6
Hello folks,

I have a general question if it is possible to use pagination inside of an ejb2.
Taken the example of the book "Java Persistence with Hibernate" (p 618):

Code:
Query query =
session.createQuery("from User u order by u.name asc")
.setMaxResults(10);
Criteria crit =
session.createCriteria(User.class)
.addOrder( Order.asc("name") )
.setFirstResult(40)
.setMaxResults(20);


So we would use maxResults = 20. And we would like to retrieve 2000
datasets which would mean 100 calls to the ejb. Is something like that
possible? What one needs to do not to loose the transaction if it is AS
based? What needs to be configured ..

Thanks a lot


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 21, 2008 10:36 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Well, it sounds like each of the 100 calls would run as a separate transaction, right? There's no guarantee that some of those transactions might not fail at some point. I mean, that's why we have transactions - because we know that databases fail, but at least a transaction allows our data to remain consistent (ACID).

What I might do it use a stateful session bean, SFSB, to keep track of which iterations have occured. If any fail, it can rerun that Hibernate query.

Just an idea. Hope it helps you Hibernate!

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


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.