db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject svn commit: r521528 - in /db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs: docu/guides/query.xml site.xml
Date Thu, 22 Mar 2007 23:36:00 GMT
Author: arminw
Date: Thu Mar 22 16:35:59 2007
New Revision: 521528

URL: http://svn.apache.org/viewvc?view=rev&rev=521528
Log:
update query docs

Modified:
    db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs/docu/guides/query.xml
    db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs/site.xml

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs/docu/guides/query.xml
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs/docu/guides/query.xml?view=diff&rev=521528&r1=521527&r2=521528
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs/docu/guides/query.xml
(original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs/docu/guides/query.xml
Thu Mar 22 16:35:59 2007
@@ -919,15 +919,73 @@
 
             </section>
 
+
+        <anchor id="functions"/>
+        <section>
+            <title>Use of scalar functions</title>
+            <p>
+                OJB supports all scalar functions with the following syntax:
+            </p>
+            <source><![CDATA[
+function()
+or
+function([value1], [value2], ...)]]></source>
+            <p>
+                So, for example you can do:
+            </p>
+            <source><![CDATA[
+Criteria crit = new Criteria().addGreaterThan("abs(deviation)", new Integer(10));
+QueryByCriteria q = QueryFactory.newQuery(Route.class, crit);
+Route route = (Route) broker.getObjectByQuery(q);
+
+
+ReportQueryByCriteria q = QueryFactory.newReportQuery(Author.class, new Criteria());
+q.setAttributes(new String[]{"name", "sum(books.pages)"});
+q.addGroupBy("name");
+Iterator it = broker.getReportQueryIteratorByQuery(q);
+
+
+ReportQueryByCriteria q = QueryFactory.newReportQuery(News.class, new Criteria());
+q.setAttributes(new String[]{"content", "curdate()"});
+q.addOrderByDescending("date");
+q.addOrderByDescending("id");
+q.setWithExtents(false);
+q.setEndAtIndex(1);
+Iterator it = broker.getReportQueryIteratorByQuery(q);
+            ]]></source>
+            <p>
+                The first query asks for all routes with the absolute deviation (is field
of class Route) of ten.
+            </p>
+            <p>
+                The second query is a report query asks for the pages sum of all books of
an author grouped by
+                the author name ('name' is a field of class Author). The Author class has
a 1:n association
+                with class Book via field 'books' in class Author. In class Book the field
'pages' represents the pages
+                size of the current book.
+            </p>
+            <p>
+                The third query returns the content of the latest news associated with the
current date
+                (function 'curdate()').
+            </p>
+        </section>
+
+
         <anchor id="selectUpdate"/>
         <section>
             <title>Lock with "SELECT ... FOR UPDATE" clause</title>
             <p>
-                TODO
+                Independent from the pessimistic and optimistic locking provided
+                by OJB it is possible to use native database locks via the "FOR UPDATE"-expression
+                using method <code>Query.setSelectForUpdate</code>.
             </p>
+            <source><![CDATA[
+Criteria crit = new Criteria()
+        .addEquals("book.title", "A Confederacy of Dunces");
+QueryByCriteria query = QueryFactory.newQuery(Review.class, crit);
+query.setSelectForUpdate(true);
+...]]></source>
             <p>
                 Details about OJB's support for <em>optimistic locking</em> and
the
-                <em>pessimistic in-memory locking API</em> can be found in the
+                <em>pessimistic locking</em> API can be found in the
                 <a href="site:lock-manager">Locking-guide</a>.
             </p>
         </section>
@@ -936,7 +994,18 @@
         <section>
             <title>Append user-defined SQL</title>
             <p>
-                TODO
+                OJB allows to append database specific expressions at the end of the query
+                (e.g. "FOR FETCH ONLY") using method <code>Query.setQueryAffix</code>.
+            </p>
+            <source><![CDATA[
+Criteria crit = new Criteria()
+        .addEquals("book.title", "A Confederacy of Dunces");
+QueryByCriteria query = QueryFactory.newQuery(Review.class, crit);
+query.setQueryAffix("FOR FETCH ONLY");
+...]]></source>
+            <p>
+                On execution of the query OJB append the specified expression at the end
of the
+                query string. 
             </p>
         </section>
 
@@ -947,6 +1016,9 @@
         <anchor id="odmg-oql"/>
         <section>
             <title>ODMG OQL</title>
+            <p>
+                TODO
+            </p>
         </section>
 
 
@@ -954,6 +1026,9 @@
         <anchor id="jdo-oql"/>
         <section>
             <title>JDO queries</title>
+            <p>
+                TODO
+            </p>
         </section>
     </body>
 </document>

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs/site.xml
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs/site.xml?view=diff&rev=521528&r1=521527&r2=521528
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs/site.xml
(original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs/site.xml
Thu Mar 22 16:35:59 2007
@@ -192,7 +192,7 @@
                 <table-per-class href="#table-per-class"/>
                 <table-per-subclass href="#table-per-subclass"/>
             </advanced-technique>
-            <query label="OJB queries" href="query.html">
+            <query label="Querying" href="query.html">
                 <query-by-criteria href="#query-by-criteria"/>
                 <joins href="#joins"/>
                 <odmg-oql href="#odmg-oql"/>



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message