From: <fg...@us...> - 2009-02-22 20:14:18
|
Revision: 1057 http://openutils.svn.sourceforge.net/openutils/?rev=1057&view=rev Author: fgrilli Date: 2009-02-22 20:14:15 +0000 (Sun, 22 Feb 2009) Log Message: ----------- fixed wrong apt formatting 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-02-22 19:13:45 UTC (rev 1056) +++ trunk/openutils-mgnlcriteria/src/site/apt/index.apt 2009-02-22 20:14:15 UTC (rev 1057) @@ -13,7 +13,7 @@ The <<<JCRCriteriaFactory>>> is a factory for <<<Criteria>>>. <<<Criterion>>> instances are usually obtained via the factory methods on <<<Restrictions>>>. eg. - openutils-mgnlcriteria API is blatantly inspired by {{{http://www.hibernate.org/hib_docs/reference/en/html/querycriteria.html}} Hibernate's Criteria API}. + openutils-mgnlcriteria API is blatantly inspired by {{{http://www.hibernate.org/hib_docs/reference/en/html/querycriteria.html} Hibernate's Criteria API}}. <<openutils-mgnlcriteria requires JDK 1.5.x or superior>> @@ -21,7 +21,7 @@ People already familiar with Hibernate's Criteria will find almost no difference (type names and methods have been kept the same on purpose, whenever possible): you create a <<<Criteria>>> object with one of the static methods in <<<JCRCriteriaFactory>>> and start adding <<<Restrictions>>> and a final optional <<<Order>>>. - Then you call the <<<list()>>> method to get your <<<Collection>>> of results (basically instances of info.magnolia.cms.core.Content). As in Hibernate's Criteria, method chaining is supported. + Then you call the <<<list()>>> method to get your <<<Collection>>> of results (basically instances of <<<info.magnolia.cms.core.Content>>>). As in Hibernate's Criteria, method chaining is supported. Here is an example: +----------------------------------------------+ @@ -36,13 +36,14 @@ Restrictions.between("@birthDate", begin, end).addOrder( Order.desc("@jcr:score()")).list(); - will be translated into the following xpath statement - - <<<//dogs//*[((jcr:contains(@name, 'Nana')) and (@weight>10.0) and (@birthDate >=xs:dateTime('2004-01-01T00:00:00.000+00:00') and @birthDate <=xs:dateTime('2008-12-01T23:59:59.000+00:00')))] order by @jcr:score() descending>>> +----------------------------------------------+ - Another handy feature is the possibility to specify a different type to be returned in the results Collection. eg. + will be translated into the following xpath statement + <<<//dogs//*[((jcr:contains(@name, 'Nana')) and (@weight>10.0) and (@birthDate >=xs:dateTime('2004-01-01T00:00:00.000+00:00') and @birthDate <=xs:dateTime('2008-12-01T23:59:59.000+00:00')))] order by @jcr:score() descending>>> + + Another handy feature is the possibility to specify a different type to be returned in the results Collection. eg. + +----------------------------------------------+ Collection<Pet> pets = JCRCriteriaFactory.createMgnlCriteria("//dogs//*", MgnlContext.getQueryManager("website"), "mgnl:content", Pet.class).add( @@ -50,11 +51,13 @@ Restrictions.gt("@weight", new Float(10))).add( Restrictions.between("@birthDate", begin, end).addOrder( Order.desc("@jcr:score()")).list(); ++----------------------------------------------+ Internally, this will use <<<info.magnolia.content2bean.Content2BeanUtil.toBean()>>> to transform nodes into beans. So, for example, if you have a domain <<<Pet>>> class like this - + ++----------------------------------------------+ public class Pet { private String name; @@ -63,10 +66,10 @@ [getters and setters here...] } ++----------------------------------------------+ -<<<Content>>> nodes returned by the above query will be automatically converted to and populate instances of the <<<Pet>>> type. + <<<Content>>> nodes returned by the above query will be automatically converted to and populate instances of the <<<Pet>>> type. -+----------------------------------------------+ 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 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |