From: <fg...@us...> - 2009-03-01 11:49:29
|
Revision: 1068 http://openutils.svn.sourceforge.net/openutils/?rev=1068&view=rev Author: fgrilli Date: 2009-03-01 11:49:19 +0000 (Sun, 01 Mar 2009) Log Message: ----------- doc for createMgnlCriteriaWithLimit Modified Paths: -------------- trunk/openutils-mgnlcriteria/src/site/apt/index.apt Modified: trunk/openutils-mgnlcriteria/src/site/apt/index.apt =================================================================== --- trunk/openutils-mgnlcriteria/src/site/apt/index.apt 2009-03-01 11:44:17 UTC (rev 1067) +++ trunk/openutils-mgnlcriteria/src/site/apt/index.apt 2009-03-01 11:49:19 UTC (rev 1068) @@ -44,7 +44,7 @@ Anyone writing xpath queries by hand knows how painful and error-prone this can be. - Another handy feature is the possibility to specify a different type to be returned in the results Collection. eg. + You can also specify a different type to be returned in the Collection of results. eg. +----------------------------------------------+ @@ -71,8 +71,26 @@ +----------------------------------------------+ <<<Content>>> nodes returned by the above query will be automatically converted to and populate instances of the <<<Pet>>> type. - + Furthermore, you may want to have only a subset of the whole resultset returned, much like in a MySQL limit clause. + In this case, you will use the <<<JCRCriteriaFactory.createMgnlCriteriaWithLimit>>> factory method + For this to work, the underlying JCR repository implementation must support this feature (Jackrabbit 1.4+ does). + + Here is a example. + ++----------------------------------------------+ + Collection<Pet> pets = JCRCriteriaFactory.createMgnlCriteriaWithLimit("//dogs//*", MgnlContext.getQueryManager("website"), "mgnl:content", Pet.class).add( + Restrictions.contains("@name", "Nana")).add( + Restrictions.gt("@weight", new Float(10))).add( + Restrictions.between("@birthDate", begin, end). + setFirstResult(5). + setMaxResults(10). + addOrder(Order.desc("@jcr:score()")).list(); ++----------------------------------------------+ + + Notice the <<<setFirstResult(int)>>> and <<<setMaxResults(int)>>> methods. + Now calling <<<list()>>> will cause to return a subset of only ten <<<Pet>>> objects, starting from the 6th item (counting starts from 0) returned by query. + Finally, it is good to know that openutils-mgnlcriteria API catches all checked exceptions thrown by JCR and Magnolia and wraps them into its own runtime <<<net.sourceforge.openutils.mgnlcriteria.jcr.query.JCRQueryException>>>, leaving to the API user the choice whether to catch it or not and, when needed, get to the original cause of error. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |