-->
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.  [ 4 posts ] 
Author Message
 Post subject: Problem with paging of results
PostPosted: Wed Oct 29, 2003 5:55 pm 
Newbie

Joined: Wed Oct 29, 2003 5:51 pm
Posts: 4
We've been using Hibernate for quite some time in JLCP but we've had a problem with the paging of results in any collection. The code we're using for collection paging is the following:

List topicList = null;
Session session = null;

try
{
session = this.sessionManager.getHibernateSession();
String query = "from topic in class org.jlcp.module.forum.model.Message where topic.parentMessage is null and topic.approved=true and topic.category="+category.getId() + " order by topic.creationDate desc";
Query q = session.createFilter(topicList, query); // the trivial filter
q.setMaxResults(perPage);
// Substract one from the page so we can enter pages 1-infinity, but
// but first result is 0-(infinity-1)
q.setFirstResult(perPage * (page-1));
topicList = q.list();
}
catch (HibernateException he)
{
throw new PersistenceException(he);
}
finally
{
this.sessionManager.flushCommitCloseSession(session);
}

This code generates the following exception each time it runs:

org.jlcp.infrastructure.persistence.exceptions.PersistenceException: net.sf.hibernate.TransientObjectException: Collection was not yet persistent
at org.jlcp.module.forum.provider.hibernate.dao.CategoryDAO.getModeratedTopics(CategoryDAO.java:255)
at org.jlcp.module.forum.ForumManager.getModeratedTopics(ForumManager.java:81)
at org.jlcp.module.forum.web.taglib.topic.HasTopics.doStartTag(HasTopics.java:78)

....

Caused by: net.sf.hibernate.TransientObjectException: Collection was not yet persistent
at net.sf.hibernate.impl.SessionImpl.getFilterTranslator(SessionImpl.java:3381)
at net.sf.hibernate.impl.SessionImpl.filter(SessionImpl.java:3415)
at net.sf.hibernate.impl.FilterImpl.list(FilterImpl.java:42)
at org.jlcp.module.forum.provider.hibernate.dao.CategoryDAO.getModeratedTopics(CategoryDAO.java:251)


Any help here would be great, as its really killing me!

Thanks in advance,
Matt
matt@javalobby.org


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 29, 2003 6:54 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Collection filters are only for persistent collections, ie. for collections that are properties of an entity associated with the session.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 29, 2003 7:11 pm 
Newbie

Joined: Wed Oct 29, 2003 5:51 pm
Posts: 4
So is there any way to do this with non-persistant collections? I suppose we could do it on the topics in a forum if those topics were a set on the category object itself?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 29, 2003 7:15 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
correct.


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