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. |
From: <fg...@us...> - 2009-02-23 12:48:08
|
Revision: 1061 http://openutils.svn.sourceforge.net/openutils/?rev=1061&view=rev Author: fgrilli Date: 2009-02-23 12:48:05 +0000 (Mon, 23 Feb 2009) Log Message: ----------- improved doc 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 20:27:29 UTC (rev 1060) +++ trunk/openutils-mgnlcriteria/src/site/apt/index.apt 2009-02-23 12:48:05 UTC (rev 1061) @@ -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 (that is instances of <<<info.magnolia.cms.core.Content>>>). As in Hibernate's Criteria, method chaining is supported. Here is an example: +----------------------------------------------+ @@ -30,7 +30,7 @@ Calendar end = Calendar.getInstance(); end.set(2008, 11, 1); - Collection pets = JCRCriteriaFactory.createMgnlCriteria("//dogs//*", MgnlContext.getQueryManager("website"), "mgnl:content").add( + Collection<Content> pets = JCRCriteriaFactory.createMgnlCriteria("//dogs//*", MgnlContext.getQueryManager("website"), "mgnl:content").add( Restrictions.contains("@name", "Nana")).add( Restrictions.gt("@weight", new Float(10))).add( Restrictions.between("@birthDate", begin, end).addOrder( This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2009-02-23 18:03:51
|
Revision: 1062 http://openutils.svn.sourceforge.net/openutils/?rev=1062&view=rev Author: fgrilli Date: 2009-02-23 18:03:48 +0000 (Mon, 23 Feb 2009) Log Message: ----------- more intro 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-23 12:48:05 UTC (rev 1061) +++ trunk/openutils-mgnlcriteria/src/site/apt/index.apt 2009-02-23 18:03:48 UTC (rev 1062) @@ -38,9 +38,11 @@ +----------------------------------------------+ - will be translated into the following xpath statement + All this 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>>> + + 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. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
From: <fg...@us...> - 2009-03-01 12:34:36
|
Revision: 1070 http://openutils.svn.sourceforge.net/openutils/?rev=1070&view=rev Author: fgrilli Date: 2009-03-01 12:34:32 +0000 (Sun, 01 Mar 2009) Log Message: ----------- minor fix 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:51:05 UTC (rev 1069) +++ trunk/openutils-mgnlcriteria/src/site/apt/index.apt 2009-03-01 12:34:32 UTC (rev 1070) @@ -73,10 +73,10 @@ <<<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 + 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. + Here is an example. +----------------------------------------------+ Collection<Pet> pets = JCRCriteriaFactory.createMgnlCriteriaWithLimit("//dogs//*", MgnlContext.getQueryManager("website"), "mgnl:content", Pet.class).add( This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2009-06-06 12:53:14
|
Revision: 1240 http://openutils.svn.sourceforge.net/openutils/?rev=1240&view=rev Author: fgrilli Date: 2009-06-06 12:30:30 +0000 (Sat, 06 Jun 2009) Log Message: ----------- Added warning about objects returned by this factory not being thread-safe 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-06-06 12:15:46 UTC (rev 1239) +++ trunk/openutils-mgnlcriteria/src/site/apt/index.apt 2009-06-06 12:30:30 UTC (rev 1240) @@ -66,7 +66,7 @@ private Float weight; private Calendar birthDate; - [getters and setters here...] + //getters and setters here... } +----------------------------------------------+ @@ -91,6 +91,10 @@ 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. + A word of warning about implementations returned by <<<JCRCriteriaFactory>>>. They are NOT thread-safe, therefore client code + wishing to use one of them as a shared global variable MUST coordinate access to it. These objects are actually meant to be + instantiated and used within a method scope (e.g. a service method), where no concurrent issues arise. + 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. |