-->
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: Lazy load and then limiting the results
PostPosted: Wed Sep 05, 2007 7:39 pm 
Newbie

Joined: Wed Sep 05, 2007 7:35 pm
Posts: 3
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.0

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:
Mysql 5.0.38

I am doing something along the following

Query query =
session.createQuery("from org.spirit.bean.impl.BotListCoreUsers user where user.userName = :userName order by user.createdOn desc LIMIT 0, 50");
String finUser = KeywordProcessor.filterAlphaNumeric(userName);
query.setString("userName", finUser);
query.setMaxResults(50);
BotListCoreUsers user = (BotListCoreUsers) query.uniqueResult();
List l = user.getLinks();
// lazy load the link
for (Iterator it = l.iterator(); it.hasNext(); ) {
Object obj = it.next();
}


I am loading a "one-to-many" relationship and on the "many" "user.getLinks() ... how can I limit the number of results?

Limit the results of the "one-to-many" at this comment "// lazy load the link"

Berlin Brown
http://www.botspiritcompany.com


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.