Paging Issue in JLCP
"Matthew Schmidt" <[email protected]> Wed, 29 Oct 2003 19:38:40 -0500
| Newsgroups | gmane.comp.java.javalobby.communityplatform |
|---|---|
| Message-ID | <006001c39e7e$2ab41a20$0181a8c0@blackhole> |
This is a multi-part message in MIME format.
------=_NextPart_000_005D_01C39E54.416BA140
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi Guys,
I got some feedback from Gavin of Hibernate on our little issue that =
is keeping paging in forums and private messaging from working. It =
appears that the code we're using for filtering a collection will only =
work on a persistence collection, not one that is generated by the query =
language in Hibernate, hence the transient exception about the =
collection needing to be persistant :) One option is use this on a =
persistence collection (ie, store replies on a thread or threads in a =
forum), which we may already be doing. The current code is:
try=20
{=20
session =3D this.sessionManager.getHibernateSession();=20
String query =3D "from topic in class =
org.jlcp.module.forum.model.Message where topic.parentMessage is null =
and topic.approved=3Dtrue and topic.category=3D"+category.getId() + " =
order by topic.creationDate desc";=20
Query q =3D session.createFilter(topicList, query); // the trivial =
filter=20
q.setMaxResults(perPage);=20
// Substract one from the page so we can enter pages 1-infinity, but=20
// but first result is 0-(infinity-1)=20
q.setFirstResult(perPage * (page-1));=20
topicList =3D q.list();=20
}=20
catch (HibernateException he)=20
{=20
throw new PersistenceException(he);=20
}=20
finally=20
{=20
this.sessionManager.flushCommitCloseSession(session);=20
}=20
Any Hibernate guru's wanna take a stab at this. If so, its in =
CategoryDAO in the forums module of JLCP.
Thanks,
Matt
------=_NextPart_000_005D_01C39E54.416BA140
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2722.900" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi Guys,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> I got some feedback =
from Gavin=20
of Hibernate on our little issue that is keeping paging in forums and =
private=20
messaging from working. It appears that the code we're using for =
filtering=20
a collection will only work on a persistence collection, not one that is =
generated by the query language in Hibernate, hence the transient=20
exception about the collection needing to be persistant :) =
One option=20
is use this on a persistence collection (ie, store replies on a thread =
or=20
threads in a forum), which we may already be doing. The =
current code=20
is:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>try <BR>{ <BR>session =3D=20
this.sessionManager.getHibernateSession(); <BR>String query =3D "from =
topic in=20
class org.jlcp.module.forum.model.Message where topic.parentMessage is =
null and=20
topic.approved=3Dtrue and topic.category=3D"+category.getId() + " order =
by=20
topic.creationDate desc"; <BR>Query q =3D =
session.createFilter(topicList, query);=20
// the trivial filter <BR>q.setMaxResults(perPage); <BR>// Substract one =
from=20
the page so we can enter pages 1-infinity, but <BR>// but first result =
is=20
0-(infinity-1) <BR>q.setFirstResult(perPage * (page-1)); <BR>topicList =
=3D=20
q.list(); <BR>} <BR>catch (HibernateException he) <BR>{ <BR>throw new=20
PersistenceException(he); <BR>} <BR>finally <BR>{=20
<BR>this.sessionManager.flushCommitCloseSession(session); <BR>}=20
</FONT><BR></DIV>
<DIV><FONT face=3DArial size=3D2>Any Hibernate guru's wanna take a stab =
at=20
this. If so, its in CategoryDAO in the forums module of =
JLCP.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Thanks,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Matt</FONT></DIV>
<DIV> </DIV></BODY></HTML>
------=_NextPart_000_005D_01C39E54.416BA140--