<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.3199" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Developping a pagination module for an open source
hibernate-struts based project </FONT></DIV>
<DIV><FONT face=Arial size=2>(<A
href="http://smartweb.sourceforge.net">http://smartweb.sourceforge.net</A>)</FONT></DIV>
<DIV><FONT face=Arial size=2>i was envolved in the problem of how to extrapolate
the results size of a given generic query (sql query, hql query
or criteria)</FONT></DIV>
<DIV><FONT face=Arial size=2>My first solution consisted into a size() call on
the returned collection but this means to extract the collection from the
db</FONT></DIV>
<DIV><FONT face=Arial size=2>for knowing the result size.
</FONT></DIV>
<DIV><FONT face=Arial size=2>With hibernate 3 the solution for criteria was too
easy and consists into add Projection on the given generic Criteria
object</FONT></DIV>
<DIV><FONT face=Arial size=2>that otherwise of the session.iterate() solution
doesn't need to extract any raws . The only result extracted is the Integer
result of the count wrapped query.</FONT></DIV>
<DIV><FONT face=Arial size=2>Otherwise an analoughe solution for Hql/SQL Query
is not very easy because of the protected visibility of the getNamedParams()
method of org.hibernate.impl.AbstractQueryImpl</FONT></DIV>
<DIV><FONT face=Arial size=2>class. </FONT></DIV>
<DIV><FONT face=Arial size=2>this deny any users to access to the query
parameters needed to wrap and execute query.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>To resolve this problem i tought a generich
solution that improves query class adding a count() public method</FONT></DIV>
<DIV><FONT face=Arial size=2>that allows to ask for a query result preview
count.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>You can ask a given prepared query:</FONT></DIV>
<DIV><FONT face=Arial size=2> - for uniqueresult: with the uniqueresult
method</FONT></DIV>
<DIV><FONT face=Arial size=2> - for raw list: with the list
method</FONT></DIV>
<DIV><FONT face=Arial size=2> - for raw count: with the count
method </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>My implementation class are attached.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I hope i could support the project with this
little work...</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Gaetano Perrone</FONT></DIV></BODY></HTML>