You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@db.apache.org by an...@apache.org on 2014/01/05 11:08:46 UTC
svn commit: r892842 [9/15] - in /websites/production/db/content/jdo: ./
guides/ releases/
Modified: websites/production/db/content/jdo/jdoql.html
==============================================================================
--- websites/production/db/content/jdo/jdoql.html (original)
+++ websites/production/db/content/jdo/jdoql.html Sun Jan 5 10:08:45 2014
@@ -1,5 +1,5 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<!-- Generated by Apache Maven Doxia Site Renderer 1.3 at Nov 4, 2013 -->
+<!-- Generated by Apache Maven Doxia Site Renderer 1.3 at Jan 5, 2014 -->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
@@ -11,7 +11,7 @@
@import url("./css/site.css");
</style>
<link rel="stylesheet" href="./css/print.css" type="text/css" media="print" />
- <meta name="Date-Revision-yyyymmdd" content="20131104" />
+ <meta name="Date-Revision-yyyymmdd" content="20140105" />
<meta http-equiv="Content-Language" content="en" />
</head>
@@ -101,7 +101,7 @@
<li class="none">
<a href="field_types.html" title="Types of Fields">Types of Fields</a>
</li>
- <li class="collapsed">
+ <li class="collapsed">
<a href="metadata.html" title="MetaData">MetaData</a>
</li>
<li class="none">
@@ -209,247 +209,247 @@
</div>
<div id="bodyColumn">
<div id="contentBox">
-
-
- <div class="section"><h2>JDOQL<a name="JDOQL"></a></h2>
- <p>
- JDO defines ways of querying objects persisted into the datastore. It provides
- its own object-based query language (JDOQL). JDOQL is designed as the Java
- developers way of having the power of SQL queries, yet retaining the Java
- object relationship that exist in their application model.
- A typical JDOQL query may be set up in one of 2 ways. Here's an example
- </p>
- <div class="source"><pre>
-Declarative JDOQL :
-Query q = pm.newQuery(mydomain.Person.class, "lastName == \"Jones\" && age < age_limit");
-q.declareParameters("double age_limit");
-List results = (List)q.execute(20.0);
-
-Single-String JDOQL :
-Query q = pm.newQuery("SELECT FROM mydomain.Person WHERE lastName == \"Jones\"" +
- " && age < :age_limit PARAMETERS double age_limit");
-List results = (List)q.execute(20.0);</pre></div>
- <p>
- So here in our example we select all "Person" objects with surname of "Jones"
- and where the persons age is below 20. The language is intuitive for Java
- developers, and is intended as their interface to accessing the persisted
- data model. As can be seen above, the query is made up of distinct parts.
- The class being selected (the SELECT clause in SQL), the filter (which equates
- to the WHERE clause in SQL), together with any sorting (the ORDER BY clause
- in SQL), etc.
- </p>
- <p>
- Before giving details on JDOQL, you can download a quick
- reference guide <a href="jdoql_quickref.pdf">here</a>
- </p>
- <br />
-
- <a name="singlestring"></a>
- <div class="section"><h3>Single-String JDOQL<a name="Single-String_JDOQL"></a></h3>
- <p>
- In traditional (declarative) JDOQL (JDO 1.0) it was necessary to specify
- the component parts (filter, candidate class, ordering, etc) of the query
- using the mutator methods on the Query. In JDO 2 you can now specify it
- all in a single string. This string has to follow a particular pattern,
- but provides the convenience that many people have been asking for.
- The pattern to use is as follows
- </p>
- <div class="source"><pre>
-SELECT [UNIQUE] [<result>] [INTO <result-class>]
- [FROM <candidate-class> [EXCLUDE SUBCLASSES]]
- [WHERE <filter>]
- [VARIABLES <variable declarations>]
- [PARAMETERS <parameter declarations>]
- [<import declarations>]
- [GROUP BY <grouping>]
- [ORDER BY <ordering>]
- [RANGE <start>, <end>]</pre></div>
- <p>
- The "keywords" in the query are shown in UPPER CASE but can be in
- <i>UPPER</i> or <i>lower</i> case.
- </p>
- <p>
- Lets give an example of a query using this syntax
- </p>
-<div class="source"><pre>SELECT UNIQUE FROM org.datanucleus.samples.Employee ORDER BY departmentNumber</pre></div>
- <p>
- so we form the parts of the query as before, yet here we just specify it
- all in a single call.
- </p>
- </div>
-
- <div class="section"><h3>Accessing Fields<a name="Accessing_Fields"></a></h3>
- <p>
- In JDOQL you access fields in the query by referring to the field name.
- For example, if you are querying a class called <i>Product</i> and it has
- a field "price", then you access it like this
- </p>
- <div class="source"><pre>
-Query query = pm.newQuery(mydomain.Product.class, "price < 150.0");</pre></div>
- <p>
- In addition to the persistent fields, you can also access
- "public static final" fields of any class. You can do this as follows
- </p>
- <div class="source"><pre>
-Query query = pm.newQuery(mydomain.Product.class,
- "taxPercent < mydomain.Product.TAX_BAND_A");</pre></div>
- <p>
- So this will find all products that include a tax percentage less than
- some "BAND A" level. Where you are using "public static final" fields you
- can either fully-qualify the class name or you can include it in the
- "imports" section of the query (see later).
- </p>
- </div>
-
- <div class="section"><h3>Data types : literals<a name="Data_types_:_literals"></a></h3>
- <p>
- JDOQL supports the following literals: IntegerLiteral,
- FloatingPointLiteral, BooleanLiteral, CharacterLiteral, StringLiteral,
- and NullLiteral.
- </p>
- </div>
-
- <div class="section"><h3>Operators precedence<a name="Operators_precedence"></a></h3>
- <p>
- The following list describes the operator precedence in JDOQL.
- </p>
- <ol style="list-style-type: decimal">
- <li>Cast</li>
- <li>Unary ("~") ("!")</li>
- <li>Unary ("+") ("-")</li>
- <li>Multiplicative ("*") ("/") ("%")</li>
- <li>Additive ("+") ("-")</li>
- <li>Relational (">=") (">") ("<=") ("<") ("instanceof")</li>
- <li>Equality ("==") ("!=")</li>
- <li>Boolean logical AND ("&")</li>
- <li>Boolean logical OR ("|")</li>
- <li>Conditional AND ("&&")</li>
- <li>Conditional OR ("||")</li>
- </ol>
- </div>
-
- <div class="section"><h3>Concatenation Expressions<a name="Concatenation_Expressions"></a></h3>
- <p>
- The concatenation operator(+) concatenates a String to either another
- String or Number. Concatenations of String or Numbers to null results in
- null.
- </p>
- </div>
-
- <div class="section"><h3>Example 1 - Use of Explicit Parameters<a name="Example_1_-_Use_of_Explicit_Parameters"></a></h3>
- <p>
- Here's a simple example for finding the elements of a class with a field
- below a particular threshold level. Here we pass in the threshold value
- (<i>limit</i>), and sort the output in order of ascending price.
- </p>
- <div class="source"><pre>
-Declarative JDOQL :
-Query query = pm.newQuery(mydomain.Product.class,"price < limit");
-query.declareParameters("double limit");
-query.setOrdering("price ascending");
-List results = (List)query.execute(150.00);
-
-Single-String JDOQL :
-Query query = pm.newQuery("SELECT FROM mydomain.Product WHERE " +
- "price < limit PARAMETERS double limit ORDER BY price ASCENDING");
-List results = (List)query.execute(150.00);</pre></div>
- <p>
- For completeness, the class is shown here
- </p>
- <div class="source"><pre>
-class Product
-{
- String name;
- double price;
- java.util.Date endDate;
- ...
-}
-
-<jdo>
- <package name="mydomain">
- <class name="Product">
- <field name="name">
- <column length="100" jdbc-type="VARCHAR"/>
- </field>
- <field name="abreviation">
- <column length="20" jdbc-type="VARCHAR"/>
- </field>
- <field name="price"/>
- <field name="endDate"/>
- </class>
- </package>
-</jdo></pre></div>
- <br />
- </div>
-
- <div class="section"><h3>Example 2 - Use of Implicit Parameters<a name="Example_2_-_Use_of_Implicit_Parameters"></a></h3>
- <p>
- Let's repeat the previous query but this time using <i>implicit</i>
- parameters.
- </p>
- <div class="source"><pre>
-Declarative JDOQL :
-Query query = pm.newQuery(mydomain.Product.class,"price < :limit");
-query.setOrdering("price ascending");
-List results = (List)query.execute(150.00);
-
-Single-String JDOQL :
-Query query = pm.newQuery("SELECT FROM mydomain.Product WHERE " +
- "price < :limit ORDER BY price ASCENDING");
-List results = (List)query.execute(150.00);</pre></div>
- <p>
- So we omitted the declaration of the parameter and just prefixed it with
- a colon (:)
- </p>
- <br />
- </div>
-
- <div class="section"><h3>Example 3 - Comparison against Dates<a name="Example_3_-_Comparison_against_Dates"></a></h3>
- <p>
- Here's another example using the same Product class as above, but this
- time comparing to a Date field. Because we are using a type in our query,
- we need to <i>import</i> it ...
- just like you would in a Java class if you were using it there.
- </p>
- <div class="source"><pre>
-Declarative JDOQL :
-Query query = pm.newQuery(domain.Product.class,
- "endDate > best_before_limit");
-query.declareImports("import java.util.Date");
-query.declareParameters("Date best_before_limit");
-query.setOrdering("endDate descending");
-Collection results = (Collection)query.execute(my_date_limit);
-
-Single-String JDOQL :
-Query query = pm.newQuery("SELECT FROM mydomain.Product " +
- "WHERE endDate > best_before_limit " +
- "PARAMETERS Date best_before_limit " +
- "import java.util.Date ORDER BY endDate DESC");
-List results = (List)query.execute(my_date_limit);</pre></div>
- <br />
- </div>
-
- <div class="section"><h3>Example 4 - Instanceof<a name="Example_4_-_Instanceof"></a></h3>
- <p>
- This example demonstrates use of the "instanceof" operator. We have a
- class A that has a field "b" of type B and B has subclasses B1, B2, B3.
- Clearly the field "b" of A can be of type B, B1, B2, B3 etc, and we want
- to find all objects of type A that have the field "b" that is of type B2.
- We do it like this
- </p>
- <div class="source"><pre>
-Declarative JDOQL :
-Query query = pm.newQuery(mydomain.A.class);
-query.setFilter("b instanceof mydomain.B2");
-List results = (List)query.execute();
-
-Single-String JDOQL :
-Query query = pm.newQuery("SELECT FROM mydomain.A WHERE b instanceof mydomain.B2");
-List results = (List)query.execute();</pre></div>
- </div>
- </div>
-
-
+
+
+ <div class="section"><h2>JDOQL<a name="JDOQL"></a></h2>
+ <p>
+ JDO defines ways of querying objects persisted into the datastore. It provides
+ its own object-based query language (JDOQL). JDOQL is designed as the Java
+ developers way of having the power of SQL queries, yet retaining the Java
+ object relationship that exist in their application model.
+ A typical JDOQL query may be set up in one of 2 ways. Here's an example
+ </p>
+ <div class="source"><pre>
+Declarative JDOQL :
+Query q = pm.newQuery(mydomain.Person.class, "lastName == \"Jones\" && age < age_limit");
+q.declareParameters("double age_limit");
+List results = (List)q.execute(20.0);
+
+Single-String JDOQL :
+Query q = pm.newQuery("SELECT FROM mydomain.Person WHERE lastName == \"Jones\"" +
+ " && age < :age_limit PARAMETERS double age_limit");
+List results = (List)q.execute(20.0);</pre></div>
+ <p>
+ So here in our example we select all "Person" objects with surname of "Jones"
+ and where the persons age is below 20. The language is intuitive for Java
+ developers, and is intended as their interface to accessing the persisted
+ data model. As can be seen above, the query is made up of distinct parts.
+ The class being selected (the SELECT clause in SQL), the filter (which equates
+ to the WHERE clause in SQL), together with any sorting (the ORDER BY clause
+ in SQL), etc.
+ </p>
+ <p>
+ Before giving details on JDOQL, you can download a quick
+ reference guide <a href="jdoql_quickref.pdf">here</a>
+ </p>
+ <br />
+
+ <a name="singlestring"></a>
+ <div class="section"><h3>Single-String JDOQL<a name="Single-String_JDOQL"></a></h3>
+ <p>
+ In traditional (declarative) JDOQL (JDO 1.0) it was necessary to specify
+ the component parts (filter, candidate class, ordering, etc) of the query
+ using the mutator methods on the Query. In JDO 2 you can now specify it
+ all in a single string. This string has to follow a particular pattern,
+ but provides the convenience that many people have been asking for.
+ The pattern to use is as follows
+ </p>
+ <div class="source"><pre>
+SELECT [UNIQUE] [<result>] [INTO <result-class>]
+ [FROM <candidate-class> [EXCLUDE SUBCLASSES]]
+ [WHERE <filter>]
+ [VARIABLES <variable declarations>]
+ [PARAMETERS <parameter declarations>]
+ [<import declarations>]
+ [GROUP BY <grouping>]
+ [ORDER BY <ordering>]
+ [RANGE <start>, <end>]</pre></div>
+ <p>
+ The "keywords" in the query are shown in UPPER CASE but can be in
+ <i>UPPER</i> or <i>lower</i> case.
+ </p>
+ <p>
+ Lets give an example of a query using this syntax
+ </p>
+<div class="source"><pre>SELECT UNIQUE FROM org.datanucleus.samples.Employee ORDER BY departmentNumber</pre></div>
+ <p>
+ so we form the parts of the query as before, yet here we just specify it
+ all in a single call.
+ </p>
+ </div>
+
+ <div class="section"><h3>Accessing Fields<a name="Accessing_Fields"></a></h3>
+ <p>
+ In JDOQL you access fields in the query by referring to the field name.
+ For example, if you are querying a class called <i>Product</i> and it has
+ a field "price", then you access it like this
+ </p>
+ <div class="source"><pre>
+Query query = pm.newQuery(mydomain.Product.class, "price < 150.0");</pre></div>
+ <p>
+ In addition to the persistent fields, you can also access
+ "public static final" fields of any class. You can do this as follows
+ </p>
+ <div class="source"><pre>
+Query query = pm.newQuery(mydomain.Product.class,
+ "taxPercent < mydomain.Product.TAX_BAND_A");</pre></div>
+ <p>
+ So this will find all products that include a tax percentage less than
+ some "BAND A" level. Where you are using "public static final" fields you
+ can either fully-qualify the class name or you can include it in the
+ "imports" section of the query (see later).
+ </p>
+ </div>
+
+ <div class="section"><h3>Data types : literals<a name="Data_types_:_literals"></a></h3>
+ <p>
+ JDOQL supports the following literals: IntegerLiteral,
+ FloatingPointLiteral, BooleanLiteral, CharacterLiteral, StringLiteral,
+ and NullLiteral.
+ </p>
+ </div>
+
+ <div class="section"><h3>Operators precedence<a name="Operators_precedence"></a></h3>
+ <p>
+ The following list describes the operator precedence in JDOQL.
+ </p>
+ <ol style="list-style-type: decimal">
+ <li>Cast</li>
+ <li>Unary ("~") ("!")</li>
+ <li>Unary ("+") ("-")</li>
+ <li>Multiplicative ("*") ("/") ("%")</li>
+ <li>Additive ("+") ("-")</li>
+ <li>Relational (">=") (">") ("<=") ("<") ("instanceof")</li>
+ <li>Equality ("==") ("!=")</li>
+ <li>Boolean logical AND ("&")</li>
+ <li>Boolean logical OR ("|")</li>
+ <li>Conditional AND ("&&")</li>
+ <li>Conditional OR ("||")</li>
+ </ol>
+ </div>
+
+ <div class="section"><h3>Concatenation Expressions<a name="Concatenation_Expressions"></a></h3>
+ <p>
+ The concatenation operator(+) concatenates a String to either another
+ String or Number. Concatenations of String or Numbers to null results in
+ null.
+ </p>
+ </div>
+
+ <div class="section"><h3>Example 1 - Use of Explicit Parameters<a name="Example_1_-_Use_of_Explicit_Parameters"></a></h3>
+ <p>
+ Here's a simple example for finding the elements of a class with a field
+ below a particular threshold level. Here we pass in the threshold value
+ (<i>limit</i>), and sort the output in order of ascending price.
+ </p>
+ <div class="source"><pre>
+Declarative JDOQL :
+Query query = pm.newQuery(mydomain.Product.class,"price < limit");
+query.declareParameters("double limit");
+query.setOrdering("price ascending");
+List results = (List)query.execute(150.00);
+
+Single-String JDOQL :
+Query query = pm.newQuery("SELECT FROM mydomain.Product WHERE " +
+ "price < limit PARAMETERS double limit ORDER BY price ASCENDING");
+List results = (List)query.execute(150.00);</pre></div>
+ <p>
+ For completeness, the class is shown here
+ </p>
+ <div class="source"><pre>
+class Product
+{
+ String name;
+ double price;
+ java.util.Date endDate;
+ ...
+}
+
+<jdo>
+ <package name="mydomain">
+ <class name="Product">
+ <field name="name">
+ <column length="100" jdbc-type="VARCHAR"/>
+ </field>
+ <field name="abreviation">
+ <column length="20" jdbc-type="VARCHAR"/>
+ </field>
+ <field name="price"/>
+ <field name="endDate"/>
+ </class>
+ </package>
+</jdo></pre></div>
+ <br />
+ </div>
+
+ <div class="section"><h3>Example 2 - Use of Implicit Parameters<a name="Example_2_-_Use_of_Implicit_Parameters"></a></h3>
+ <p>
+ Let's repeat the previous query but this time using <i>implicit</i>
+ parameters.
+ </p>
+ <div class="source"><pre>
+Declarative JDOQL :
+Query query = pm.newQuery(mydomain.Product.class,"price < :limit");
+query.setOrdering("price ascending");
+List results = (List)query.execute(150.00);
+
+Single-String JDOQL :
+Query query = pm.newQuery("SELECT FROM mydomain.Product WHERE " +
+ "price < :limit ORDER BY price ASCENDING");
+List results = (List)query.execute(150.00);</pre></div>
+ <p>
+ So we omitted the declaration of the parameter and just prefixed it with
+ a colon (:)
+ </p>
+ <br />
+ </div>
+
+ <div class="section"><h3>Example 3 - Comparison against Dates<a name="Example_3_-_Comparison_against_Dates"></a></h3>
+ <p>
+ Here's another example using the same Product class as above, but this
+ time comparing to a Date field. Because we are using a type in our query,
+ we need to <i>import</i> it ...
+ just like you would in a Java class if you were using it there.
+ </p>
+ <div class="source"><pre>
+Declarative JDOQL :
+Query query = pm.newQuery(domain.Product.class,
+ "endDate > best_before_limit");
+query.declareImports("import java.util.Date");
+query.declareParameters("Date best_before_limit");
+query.setOrdering("endDate descending");
+Collection results = (Collection)query.execute(my_date_limit);
+
+Single-String JDOQL :
+Query query = pm.newQuery("SELECT FROM mydomain.Product " +
+ "WHERE endDate > best_before_limit " +
+ "PARAMETERS Date best_before_limit " +
+ "import java.util.Date ORDER BY endDate DESC");
+List results = (List)query.execute(my_date_limit);</pre></div>
+ <br />
+ </div>
+
+ <div class="section"><h3>Example 4 - Instanceof<a name="Example_4_-_Instanceof"></a></h3>
+ <p>
+ This example demonstrates use of the "instanceof" operator. We have a
+ class A that has a field "b" of type B and B has subclasses B1, B2, B3.
+ Clearly the field "b" of A can be of type B, B1, B2, B3 etc, and we want
+ to find all objects of type A that have the field "b" that is of type B2.
+ We do it like this
+ </p>
+ <div class="source"><pre>
+Declarative JDOQL :
+Query query = pm.newQuery(mydomain.A.class);
+query.setFilter("b instanceof mydomain.B2");
+List results = (List)query.execute();
+
+Single-String JDOQL :
+Query query = pm.newQuery("SELECT FROM mydomain.A WHERE b instanceof mydomain.B2");
+List results = (List)query.execute();</pre></div>
+ </div>
+ </div>
+
+
</div>
</div>
@@ -458,7 +458,7 @@ List results = (List)query.execute();</p
</div>
<div id="footer">
<div class="xright">
- Copyright © 2005-2013.
+ Copyright © 2005-2014.
All Rights Reserved.
</div>
Modified: websites/production/db/content/jdo/jdoql_methods.html
==============================================================================
--- websites/production/db/content/jdo/jdoql_methods.html (original)
+++ websites/production/db/content/jdo/jdoql_methods.html Sun Jan 5 10:08:45 2014
@@ -1,5 +1,5 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<!-- Generated by Apache Maven Doxia Site Renderer 1.3 at Nov 4, 2013 -->
+<!-- Generated by Apache Maven Doxia Site Renderer 1.3 at Jan 5, 2014 -->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
@@ -11,7 +11,7 @@
@import url("./css/site.css");
</style>
<link rel="stylesheet" href="./css/print.css" type="text/css" media="print" />
- <meta name="Date-Revision-yyyymmdd" content="20131104" />
+ <meta name="Date-Revision-yyyymmdd" content="20140105" />
<meta http-equiv="Content-Language" content="en" />
</head>
@@ -101,7 +101,7 @@
<li class="none">
<a href="field_types.html" title="Types of Fields">Types of Fields</a>
</li>
- <li class="collapsed">
+ <li class="collapsed">
<a href="metadata.html" title="MetaData">MetaData</a>
</li>
<li class="none">
@@ -209,299 +209,299 @@
</div>
<div id="bodyColumn">
<div id="contentBox">
-
-
- <div class="section"><h2>JDOQL : Methods<a name="JDOQL_:_Methods"></a></h2>
- <p>
- When writing the "filter" for a JDOQL Query you can make use of some methods on the various
- Java types. The range of methods included as standard in JDOQL is not as flexible as with
- the true Java types, but the ones that are available are typically of much use.
- </p>
- <br />
- <div class="section"><h3>String Methods<a name="String_Methods"></a></h3>
- <table border="0" class="bodyTable">
- <tr class="a">
- <th width="220">Method</th>
- <th>Description</th>
- </tr>
- <tr class="b">
- <td>startsWith(String)</td>
- <td>Returns if the string starts with the passed string</td>
- </tr>
- <tr class="a">
- <td>startsWith(String, int)</td>
- <td>Returns if the string starts with the passed string, after the specified position</td>
- </tr>
- <tr class="b">
- <td>endsWith(String)</td>
- <td>Returns if the string ends with the passed string</td>
- </tr>
- <tr class="a">
- <td>indexOf(String)</td>
- <td>Returns the first position of the passed string</td>
- </tr>
- <tr class="b">
- <td>indexOf(String, int)</td>
- <td>Returns the position of the passed string, after the passed position</td>
- </tr>
- <tr class="a">
- <td>substring(int)</td>
- <td>Returns the substring starting from the passed position</td>
- </tr>
- <tr class="b">
- <td>substring(int, int)</td>
- <td>Returns the substring between the passed positions</td>
- </tr>
- <tr class="a">
- <td>toLowerCase()</td>
- <td>Returns the string in lowercase</td>
- </tr>
- <tr class="b">
- <td>toUpperCase()</td>
- <td>Retuns the string in UPPERCASE</td>
- </tr>
- <tr class="a">
- <td>matches(String pattern)</td>
- <td>Returns whether string matches the passed expression. The pattern argument follows the rules of
- java.lang.String.matches method.</td>
- </tr>
- <tr class="b">
- <td>trim()</td>
- <td>Retuns the string with leading/trailing spaces trimmed</td>
- </tr>
- <tr class="a">
- <td>length()</td>
- <td>Retuns the length of the string</td>
- </tr>
- <tr class="b">
- <td>charAt(int)</td>
- <td>Returns the character at the specified position of the string</td>
- </tr>
- </table>
- <p>
- Here's an example using a Product class, looking for objects which their abreviation is the
- beginning of a trade name. The trade name is provided as parameter.
- </p>
- <div class="source"><pre>
-Declarative JDOQL :
-Query query = pm.newQuery(mydomain.Product.class);
-query.setFilter(":tradeName.startsWith(this.abbreviation)");
-List results = (List)query.execute("Workbook Advanced");
-
-Single-String JDOQL :
-Query query = pm.newQuery(
- "SELECT FROM mydomain.Product " +
- "WHERE :tradeName.startsWith(this.abbreviation)");
-List results = (List)query.execute("Workbook Advanced");</pre></div>
- <br />
- <p>
- Here's another example, demonstrating the "matches" method.
- Consult the javadocs for Java regular expressions for the
- syntax of the matches input.
- </p>
- <div class="source"><pre>
-Declarative JDOQL :
-Query query = pm.newQuery(mydomain.Product.class);
-query.setFilter("this.abbreviation.matches(\"a*b\")");
-List results = (List)query.execute();
-
-Single-String JDOQL :
-Query query = pm.newQuery(
- "SELECT FROM mydomain.Product " +
- "WHERE this.abbreviation.matches(\"a*b\")");
-List results = (List)query.execute();</pre></div>
- <br />
- </div>
-
- <div class="section"><h3>Collection Methods<a name="Collection_Methods"></a></h3>
- <table border="0" class="bodyTable">
- <tr class="a">
- <th width="220">Method</th>
- <th>Description</th>
- </tr>
- <tr class="b">
- <td>isEmpty()</td>
- <td>Returns whether the collection is empty</td>
- </tr>
- <tr class="a">
- <td>contains(value)</td>
- <td>Returns whether the collection contains the passed element</td>
- </tr>
- <tr class="b">
- <td>size()</td>
- <td>Returns the number of elements in the collection</td>
- </tr>
- </table>
- <p>
- Here's an example demonstrating use of contains(). We have an Inventory class that has a
- Collection of Product objects, and we want to find the Inventory objects with 2 particular
- Products in it. Here we make use of a variable (<i>prd</i> to represent the Product being
- contained
- </p>
- <div class="source"><pre>
-Declarative JDOQL :
-Query query = pm.newQuery(mydomain.Inventory.class);
-query.setFilter("products.contains(prd) && (prd.name==\"product 1\" || prd.name==\"product 2\")");
-List results = (List)query.execute();
-
-Single-String JDOQL:
-Query query = pm.newQuery(
- "SELECT FROM mydomain.Inventory EXCLUDE SUBCLASSES " +
- "WHERE products.contains(prd) && (prd.name==\"product 1\" || prd.name==\"product 2\")");
-List results = (List)query.execute();</pre></div>
- <br />
- </div>
-
- <div class="section"><h3>List Methods<a name="List_Methods"></a></h3>
- <table border="0" class="bodyTable">
- <tr class="a">
- <th width="220">Method</th>
- <th>Description</th>
- </tr>
- <tr class="b">
- <td>get(position)</td>
- <td>Returns the element at that position in the List (JDO3.1)</td>
- </tr>
- </table>
- <br />
- </div>
-
- <div class="section"><h3>Map Methods<a name="Map_Methods"></a></h3>
- <table border="0" class="bodyTable">
- <tr class="a">
- <th width="220">Method</th>
- <th>Description</th>
- </tr>
- <tr class="b">
- <td>isEmpty()</td>
- <td>Returns whether the map is empty</td>
- </tr>
- <tr class="a">
- <td>containsKey(key)</td>
- <td>Returns whether the map contains the passed key</td>
- </tr>
- <tr class="b">
- <td>containsValue(value)</td>
- <td>Returns whether the map contains the passed value</td>
- </tr>
- <tr class="a">
- <td>get(key)</td>
- <td>Returns the value from the map with the passed key</td>
- </tr>
- <tr class="b">
- <td>size()</td>
- <td>Returns the number of entries in the map</td>
- </tr>
- </table>
- <p>
- Here's an example using a Product class as a value in a Map. Our example represents an
- organisation that has several Inventories of products. Each Inventory of products is stored
- using a Map, keyed by the Product name. The query searches for all Inventories that contain a
- product with the name "product 1".
- </p>
- <div class="source"><pre>
-Declarative JDOQL :
-Query query = pm.newQuery(mydomain.Inventory.class, "products.containsKey(\"product 1\")");
-List results = (List)query.execute();
-
-Single-String JDOQL :
-Query query = pm.newQuery(
- "SELECT FROM mydomain.Inventory EXCLUDE SUBCLASSES " +
- "WHERE products.containsKey(\"product 1\")");
-List results = (List)query.execute();</pre></div>
- <br />
- </div>
-
- <div class="section"><h3>Temporal Methods<a name="Temporal_Methods"></a></h3>
- <table border="0" class="bodyTable">
- <tr class="a">
- <th width="220">Method</th>
- <th>Description</th>
- </tr>
- <tr class="b">
- <td>getDay()</td>
- <td>Returns the day of the month</td>
- </tr>
- <tr class="a">
- <td>getMonth()</td>
- <td>Returns the month of the year</td>
- </tr>
- <tr class="b">
- <td>getYear()</td>
- <td>Returns the year</td>
- </tr>
- <tr class="a">
- <td>getHour()</td>
- <td>Returns the hour</td>
- </tr>
- <tr class="b">
- <td>getMinute()</td>
- <td>Returns the minute</td>
- </tr>
- <tr class="a">
- <td>getSecond()</td>
- <td>Returns the second</td>
- </tr>
- </table>
- <br />
- </div>
-
- <div class="section"><h3>Enum Methods<a name="Enum_Methods"></a></h3>
- <table border="0" class="bodyTable">
- <tr class="a">
- <th width="220">Method</th>
- <th>Description</th>
- </tr>
- <tr class="b">
- <td>ordinal()</td>
- <td>Returns the ordinal of the enum</td>
- </tr>
- <tr class="a">
- <td>toString()</td>
- <td>Returns the string form of the enum</td>
- </tr>
- </table>
- <br />
- </div>
-
- <div class="section"><h3>Other Methods<a name="Other_Methods"></a></h3>
- <table border="0" class="bodyTable">
- <tr class="a">
- <th width="220">Method</th>
- <th>Description</th>
- </tr>
- <tr class="b">
- <td>Math.abs(number)</td>
- <td>Returns the absolute value of the passed number</td>
- </tr>
- <tr class="a">
- <td>Math.sqrt(number)</td>
- <td>Returns the square root of the passed number</td>
- </tr>
- <tr class="b">
- <td>Math.cos(number)</td>
- <td>Returns the cosine of the passed number</td>
- </tr>
- <tr class="a">
- <td>Math.sin(number)</td>
- <td>Returns the sine of the passed number</td>
- </tr>
- <tr class="b">
- <td>Math.tan(number)</td>
- <td>Returns the tangent of the passed number</td>
- </tr>
- <tr class="a">
- <td>JDOHelper.getObjectId(object)</td>
- <td>Returns the object identity of the passed persistent object</td>
- </tr>
- <tr class="b">
- <td>JDOHelper.getVersion(object)</td>
- <td>Returns the version of the passed persistent object</td>
- </tr>
- </table>
- </div>
- </div>
-
+
+
+ <div class="section"><h2>JDOQL : Methods<a name="JDOQL_:_Methods"></a></h2>
+ <p>
+ When writing the "filter" for a JDOQL Query you can make use of some methods on the various
+ Java types. The range of methods included as standard in JDOQL is not as flexible as with
+ the true Java types, but the ones that are available are typically of much use.
+ </p>
+ <br />
+ <div class="section"><h3>String Methods<a name="String_Methods"></a></h3>
+ <table border="0" class="bodyTable">
+ <tr class="a">
+ <th width="220">Method</th>
+ <th>Description</th>
+ </tr>
+ <tr class="b">
+ <td>startsWith(String)</td>
+ <td>Returns if the string starts with the passed string</td>
+ </tr>
+ <tr class="a">
+ <td>startsWith(String, int)</td>
+ <td>Returns if the string starts with the passed string, after the specified position</td>
+ </tr>
+ <tr class="b">
+ <td>endsWith(String)</td>
+ <td>Returns if the string ends with the passed string</td>
+ </tr>
+ <tr class="a">
+ <td>indexOf(String)</td>
+ <td>Returns the first position of the passed string</td>
+ </tr>
+ <tr class="b">
+ <td>indexOf(String, int)</td>
+ <td>Returns the position of the passed string, after the passed position</td>
+ </tr>
+ <tr class="a">
+ <td>substring(int)</td>
+ <td>Returns the substring starting from the passed position</td>
+ </tr>
+ <tr class="b">
+ <td>substring(int, int)</td>
+ <td>Returns the substring between the passed positions</td>
+ </tr>
+ <tr class="a">
+ <td>toLowerCase()</td>
+ <td>Returns the string in lowercase</td>
+ </tr>
+ <tr class="b">
+ <td>toUpperCase()</td>
+ <td>Retuns the string in UPPERCASE</td>
+ </tr>
+ <tr class="a">
+ <td>matches(String pattern)</td>
+ <td>Returns whether string matches the passed expression. The pattern argument follows the rules of
+ java.lang.String.matches method.</td>
+ </tr>
+ <tr class="b">
+ <td>trim()</td>
+ <td>Retuns the string with leading/trailing spaces trimmed</td>
+ </tr>
+ <tr class="a">
+ <td>length()</td>
+ <td>Retuns the length of the string</td>
+ </tr>
+ <tr class="b">
+ <td>charAt(int)</td>
+ <td>Returns the character at the specified position of the string</td>
+ </tr>
+ </table>
+ <p>
+ Here's an example using a Product class, looking for objects which their abreviation is the
+ beginning of a trade name. The trade name is provided as parameter.
+ </p>
+ <div class="source"><pre>
+Declarative JDOQL :
+Query query = pm.newQuery(mydomain.Product.class);
+query.setFilter(":tradeName.startsWith(this.abbreviation)");
+List results = (List)query.execute("Workbook Advanced");
+
+Single-String JDOQL :
+Query query = pm.newQuery(
+ "SELECT FROM mydomain.Product " +
+ "WHERE :tradeName.startsWith(this.abbreviation)");
+List results = (List)query.execute("Workbook Advanced");</pre></div>
+ <br />
+ <p>
+ Here's another example, demonstrating the "matches" method.
+ Consult the javadocs for Java regular expressions for the
+ syntax of the matches input.
+ </p>
+ <div class="source"><pre>
+Declarative JDOQL :
+Query query = pm.newQuery(mydomain.Product.class);
+query.setFilter("this.abbreviation.matches(\"a*b\")");
+List results = (List)query.execute();
+
+Single-String JDOQL :
+Query query = pm.newQuery(
+ "SELECT FROM mydomain.Product " +
+ "WHERE this.abbreviation.matches(\"a*b\")");
+List results = (List)query.execute();</pre></div>
+ <br />
+ </div>
+
+ <div class="section"><h3>Collection Methods<a name="Collection_Methods"></a></h3>
+ <table border="0" class="bodyTable">
+ <tr class="a">
+ <th width="220">Method</th>
+ <th>Description</th>
+ </tr>
+ <tr class="b">
+ <td>isEmpty()</td>
+ <td>Returns whether the collection is empty</td>
+ </tr>
+ <tr class="a">
+ <td>contains(value)</td>
+ <td>Returns whether the collection contains the passed element</td>
+ </tr>
+ <tr class="b">
+ <td>size()</td>
+ <td>Returns the number of elements in the collection</td>
+ </tr>
+ </table>
+ <p>
+ Here's an example demonstrating use of contains(). We have an Inventory class that has a
+ Collection of Product objects, and we want to find the Inventory objects with 2 particular
+ Products in it. Here we make use of a variable (<i>prd</i> to represent the Product being
+ contained
+ </p>
+ <div class="source"><pre>
+Declarative JDOQL :
+Query query = pm.newQuery(mydomain.Inventory.class);
+query.setFilter("products.contains(prd) && (prd.name==\"product 1\" || prd.name==\"product 2\")");
+List results = (List)query.execute();
+
+Single-String JDOQL:
+Query query = pm.newQuery(
+ "SELECT FROM mydomain.Inventory EXCLUDE SUBCLASSES " +
+ "WHERE products.contains(prd) && (prd.name==\"product 1\" || prd.name==\"product 2\")");
+List results = (List)query.execute();</pre></div>
+ <br />
+ </div>
+
+ <div class="section"><h3>List Methods<a name="List_Methods"></a></h3>
+ <table border="0" class="bodyTable">
+ <tr class="a">
+ <th width="220">Method</th>
+ <th>Description</th>
+ </tr>
+ <tr class="b">
+ <td>get(position)</td>
+ <td>Returns the element at that position in the List (JDO3.1)</td>
+ </tr>
+ </table>
+ <br />
+ </div>
+
+ <div class="section"><h3>Map Methods<a name="Map_Methods"></a></h3>
+ <table border="0" class="bodyTable">
+ <tr class="a">
+ <th width="220">Method</th>
+ <th>Description</th>
+ </tr>
+ <tr class="b">
+ <td>isEmpty()</td>
+ <td>Returns whether the map is empty</td>
+ </tr>
+ <tr class="a">
+ <td>containsKey(key)</td>
+ <td>Returns whether the map contains the passed key</td>
+ </tr>
+ <tr class="b">
+ <td>containsValue(value)</td>
+ <td>Returns whether the map contains the passed value</td>
+ </tr>
+ <tr class="a">
+ <td>get(key)</td>
+ <td>Returns the value from the map with the passed key</td>
+ </tr>
+ <tr class="b">
+ <td>size()</td>
+ <td>Returns the number of entries in the map</td>
+ </tr>
+ </table>
+ <p>
+ Here's an example using a Product class as a value in a Map. Our example represents an
+ organisation that has several Inventories of products. Each Inventory of products is stored
+ using a Map, keyed by the Product name. The query searches for all Inventories that contain a
+ product with the name "product 1".
+ </p>
+ <div class="source"><pre>
+Declarative JDOQL :
+Query query = pm.newQuery(mydomain.Inventory.class, "products.containsKey(\"product 1\")");
+List results = (List)query.execute();
+
+Single-String JDOQL :
+Query query = pm.newQuery(
+ "SELECT FROM mydomain.Inventory EXCLUDE SUBCLASSES " +
+ "WHERE products.containsKey(\"product 1\")");
+List results = (List)query.execute();</pre></div>
+ <br />
+ </div>
+
+ <div class="section"><h3>Temporal Methods<a name="Temporal_Methods"></a></h3>
+ <table border="0" class="bodyTable">
+ <tr class="a">
+ <th width="220">Method</th>
+ <th>Description</th>
+ </tr>
+ <tr class="b">
+ <td>getDay()</td>
+ <td>Returns the day of the month</td>
+ </tr>
+ <tr class="a">
+ <td>getMonth()</td>
+ <td>Returns the month of the year</td>
+ </tr>
+ <tr class="b">
+ <td>getYear()</td>
+ <td>Returns the year</td>
+ </tr>
+ <tr class="a">
+ <td>getHour()</td>
+ <td>Returns the hour</td>
+ </tr>
+ <tr class="b">
+ <td>getMinute()</td>
+ <td>Returns the minute</td>
+ </tr>
+ <tr class="a">
+ <td>getSecond()</td>
+ <td>Returns the second</td>
+ </tr>
+ </table>
+ <br />
+ </div>
+
+ <div class="section"><h3>Enum Methods<a name="Enum_Methods"></a></h3>
+ <table border="0" class="bodyTable">
+ <tr class="a">
+ <th width="220">Method</th>
+ <th>Description</th>
+ </tr>
+ <tr class="b">
+ <td>ordinal()</td>
+ <td>Returns the ordinal of the enum</td>
+ </tr>
+ <tr class="a">
+ <td>toString()</td>
+ <td>Returns the string form of the enum</td>
+ </tr>
+ </table>
+ <br />
+ </div>
+
+ <div class="section"><h3>Other Methods<a name="Other_Methods"></a></h3>
+ <table border="0" class="bodyTable">
+ <tr class="a">
+ <th width="220">Method</th>
+ <th>Description</th>
+ </tr>
+ <tr class="b">
+ <td>Math.abs(number)</td>
+ <td>Returns the absolute value of the passed number</td>
+ </tr>
+ <tr class="a">
+ <td>Math.sqrt(number)</td>
+ <td>Returns the square root of the passed number</td>
+ </tr>
+ <tr class="b">
+ <td>Math.cos(number)</td>
+ <td>Returns the cosine of the passed number</td>
+ </tr>
+ <tr class="a">
+ <td>Math.sin(number)</td>
+ <td>Returns the sine of the passed number</td>
+ </tr>
+ <tr class="b">
+ <td>Math.tan(number)</td>
+ <td>Returns the tangent of the passed number</td>
+ </tr>
+ <tr class="a">
+ <td>JDOHelper.getObjectId(object)</td>
+ <td>Returns the object identity of the passed persistent object</td>
+ </tr>
+ <tr class="b">
+ <td>JDOHelper.getVersion(object)</td>
+ <td>Returns the version of the passed persistent object</td>
+ </tr>
+ </table>
+ </div>
+ </div>
+
</div>
</div>
@@ -510,7 +510,7 @@ List results = (List)query.execute();</p
</div>
<div id="footer">
<div class="xright">
- Copyright © 2005-2013.
+ Copyright © 2005-2014.
All Rights Reserved.
</div>
Modified: websites/production/db/content/jdo/jdoql_result.html
==============================================================================
--- websites/production/db/content/jdo/jdoql_result.html (original)
+++ websites/production/db/content/jdo/jdoql_result.html Sun Jan 5 10:08:45 2014
@@ -1,5 +1,5 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<!-- Generated by Apache Maven Doxia Site Renderer 1.3 at Nov 4, 2013 -->
+<!-- Generated by Apache Maven Doxia Site Renderer 1.3 at Jan 5, 2014 -->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
@@ -11,7 +11,7 @@
@import url("./css/site.css");
</style>
<link rel="stylesheet" href="./css/print.css" type="text/css" media="print" />
- <meta name="Date-Revision-yyyymmdd" content="20131104" />
+ <meta name="Date-Revision-yyyymmdd" content="20140105" />
<meta http-equiv="Content-Language" content="en" />
</head>
@@ -101,7 +101,7 @@
<li class="none">
<a href="field_types.html" title="Types of Fields">Types of Fields</a>
</li>
- <li class="collapsed">
+ <li class="collapsed">
<a href="metadata.html" title="MetaData">MetaData</a>
</li>
<li class="none">
@@ -209,106 +209,106 @@
</div>
<div id="bodyColumn">
<div id="contentBox">
-
-
- <div class="section"><h2>JDOQL : Result<a name="JDOQL_:_Result"></a></h2>
- <p>
- As we have seen, a JDOQL query is made up of different parts. In this section we look at the
- <i>result</i> part of the query. The result is what we want returning. By default (when not specifying
- the result) the objects returned will be of the candidate class type, where they match the query
- filter. Firstly let's look at what you can include in the <i>result</i> clause.
- </p>
- <ul>
- <li><i>this</i> - the candidate instance</li>
- <li>A field name</li>
- <li>A variable</li>
- <li>A parameter (though why you would want a parameter returning is hard to see since you input
- the value in the first place)</li>
- <li>An aggregate (count(), avg(), sum(), min(), max())</li>
- <li>An expression involving a field (e.g "field1 + 1")</li>
- <li>A navigational expression (navigating from one field to another ... e.g "field1.field4")</li>
- </ul>
- <p>
- The result is specified in JDOQL like this
- </p>
- <div class="source"><pre>query.setResult("count(field1), field2");</pre></div>
- <p>
- In <b>Single-String JDOQL</b> you would specify it directly.
- </p>
- <br />
-
- <div class="section"><h3>Result type<a name="Result_type"></a></h3>
- <p>
- What you specify in the <i>result</i> defines what form of result you get back.
- </p>
- <ul>
- <li><b>Object</b> - this is returned if you have only a single row in the results and a single
- column. This is achived when you specified either UNIQUE, or just an aggregate
- (e.g "max(field2)")</li>
- <li><b>Object[]</b> - this is returned if you have only a single row in the results, but more
- than 1 column (e.g "max(field1), avg(field2)")</li>
- <li><b>List<Object></b> - this is returned if you have only a single column in the result,
- and you don't have only aggregates in the result (e.g "field2")</li>
- <li><b>List<Object[]></b> - this is returned if you have more than 1 column in the result,
- and you don't have only aggregates in the result (e.g "field2, avg(field3)")</li>
- </ul>
- </div>
-
- <div class="section"><h3>Aggregates<a name="Aggregates"></a></h3>
- <p>
- There are situations when you want to return a single number for a column, representing an
- aggregate of the values of all records. There are 5 standard JDO2 aggregate functions available.
- These are
- </p>
- <ul>
- <li><b>avg(val)</b> - returns the average of "val". "val" can be a field, numeric field expression
- or "distinct field".</li>
- <li><b>sum(val)</b> - returns the sum of "val". "val" can be a field, numeric field expression,
- or "distinct field".</li>
- <li><b>count(val)</b> - returns the count of records of "val". "val" can be a field, or can be
- "this", or "distinct field".</li>
- <li><b>min(val)</b> - returns the minimum of "val". "val" can be a field</li>
- <li><b>max(val)</b> - returns the maximum of "val". "val" can be a field</li>
- </ul>
- <p>
- So to utilise these you could specify something like
- </p>
- <div class="source"><pre>
-Query q = pm.newQuery("SELECT max(price), min(price) FROM mydomain.Product WHERE status == 1");</pre></div>
- <p>
- This will return a single row of results with 2 values, the maximum price and the minimum price of
- all products that have status code of 1.
- </p>
- <br />
- </div>
-
- <div class="section"><h3>Example - Use of aggregates<a name="Example_-_Use_of_aggregates"></a></h3>
- <p>
- JDO 2 introduces the ability to use aggregates in queries. Here's another example using the
- same Product class as above, but this time looking for the maximum price of products that are
- CD Players. Note that the result for this particular query will be of type Double since there
- is a single double precision value being returned via the "result".
- </p>
- <div class="source"><pre>
-Declarative JDOQL :
-Query query = pm.newQuery(mydomain.Product.class);
-query.setFilter("name == \"CD Player\"");
-query.setResult("max(this.price)");
-List results = (List)query.execute();
-Iterator iter = c.iterator();
-Double max_price = (Double)iter.next();
-
-Single-String JDOQL :
-Query query = pm.newQuery("SELECT max(price) FROM mydomain.Product WHERE name == \"CD Player\"");
-List results = (List)query.execute();
-Iterator iter = c.iterator();
-Double max_price = (Double)iter.next();</pre></div>
- <br />
- </div>
-
- </div>
-
-
+
+
+ <div class="section"><h2>JDOQL : Result<a name="JDOQL_:_Result"></a></h2>
+ <p>
+ As we have seen, a JDOQL query is made up of different parts. In this section we look at the
+ <i>result</i> part of the query. The result is what we want returning. By default (when not specifying
+ the result) the objects returned will be of the candidate class type, where they match the query
+ filter. Firstly let's look at what you can include in the <i>result</i> clause.
+ </p>
+ <ul>
+ <li><i>this</i> - the candidate instance</li>
+ <li>A field name</li>
+ <li>A variable</li>
+ <li>A parameter (though why you would want a parameter returning is hard to see since you input
+ the value in the first place)</li>
+ <li>An aggregate (count(), avg(), sum(), min(), max())</li>
+ <li>An expression involving a field (e.g "field1 + 1")</li>
+ <li>A navigational expression (navigating from one field to another ... e.g "field1.field4")</li>
+ </ul>
+ <p>
+ The result is specified in JDOQL like this
+ </p>
+ <div class="source"><pre>query.setResult("count(field1), field2");</pre></div>
+ <p>
+ In <b>Single-String JDOQL</b> you would specify it directly.
+ </p>
+ <br />
+
+ <div class="section"><h3>Result type<a name="Result_type"></a></h3>
+ <p>
+ What you specify in the <i>result</i> defines what form of result you get back.
+ </p>
+ <ul>
+ <li><b>Object</b> - this is returned if you have only a single row in the results and a single
+ column. This is achived when you specified either UNIQUE, or just an aggregate
+ (e.g "max(field2)")</li>
+ <li><b>Object[]</b> - this is returned if you have only a single row in the results, but more
+ than 1 column (e.g "max(field1), avg(field2)")</li>
+ <li><b>List<Object></b> - this is returned if you have only a single column in the result,
+ and you don't have only aggregates in the result (e.g "field2")</li>
+ <li><b>List<Object[]></b> - this is returned if you have more than 1 column in the result,
+ and you don't have only aggregates in the result (e.g "field2, avg(field3)")</li>
+ </ul>
+ </div>
+
+ <div class="section"><h3>Aggregates<a name="Aggregates"></a></h3>
+ <p>
+ There are situations when you want to return a single number for a column, representing an
+ aggregate of the values of all records. There are 5 standard JDO2 aggregate functions available.
+ These are
+ </p>
+ <ul>
+ <li><b>avg(val)</b> - returns the average of "val". "val" can be a field, numeric field expression
+ or "distinct field".</li>
+ <li><b>sum(val)</b> - returns the sum of "val". "val" can be a field, numeric field expression,
+ or "distinct field".</li>
+ <li><b>count(val)</b> - returns the count of records of "val". "val" can be a field, or can be
+ "this", or "distinct field".</li>
+ <li><b>min(val)</b> - returns the minimum of "val". "val" can be a field</li>
+ <li><b>max(val)</b> - returns the maximum of "val". "val" can be a field</li>
+ </ul>
+ <p>
+ So to utilise these you could specify something like
+ </p>
+ <div class="source"><pre>
+Query q = pm.newQuery("SELECT max(price), min(price) FROM mydomain.Product WHERE status == 1");</pre></div>
+ <p>
+ This will return a single row of results with 2 values, the maximum price and the minimum price of
+ all products that have status code of 1.
+ </p>
+ <br />
+ </div>
+
+ <div class="section"><h3>Example - Use of aggregates<a name="Example_-_Use_of_aggregates"></a></h3>
+ <p>
+ JDO 2 introduces the ability to use aggregates in queries. Here's another example using the
+ same Product class as above, but this time looking for the maximum price of products that are
+ CD Players. Note that the result for this particular query will be of type Double since there
+ is a single double precision value being returned via the "result".
+ </p>
+ <div class="source"><pre>
+Declarative JDOQL :
+Query query = pm.newQuery(mydomain.Product.class);
+query.setFilter("name == \"CD Player\"");
+query.setResult("max(this.price)");
+List results = (List)query.execute();
+Iterator iter = c.iterator();
+Double max_price = (Double)iter.next();
+
+Single-String JDOQL :
+Query query = pm.newQuery("SELECT max(price) FROM mydomain.Product WHERE name == \"CD Player\"");
+List results = (List)query.execute();
+Iterator iter = c.iterator();
+Double max_price = (Double)iter.next();</pre></div>
+ <br />
+ </div>
+
+ </div>
+
+
</div>
</div>
@@ -317,7 +317,7 @@ Double max_price = (Double)iter.next();<
</div>
<div id="footer">
<div class="xright">
- Copyright © 2005-2013.
+ Copyright © 2005-2014.
All Rights Reserved.
</div>
Modified: websites/production/db/content/jdo/jdoquery_dtd.html
==============================================================================
--- websites/production/db/content/jdo/jdoquery_dtd.html (original)
+++ websites/production/db/content/jdo/jdoquery_dtd.html Sun Jan 5 10:08:45 2014
@@ -1,5 +1,5 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<!-- Generated by Apache Maven Doxia Site Renderer 1.3 at Nov 4, 2013 -->
+<!-- Generated by Apache Maven Doxia Site Renderer 1.3 at Jan 5, 2014 -->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
@@ -11,7 +11,7 @@
@import url("./css/site.css");
</style>
<link rel="stylesheet" href="./css/print.css" type="text/css" media="print" />
- <meta name="Date-Revision-yyyymmdd" content="20131104" />
+ <meta name="Date-Revision-yyyymmdd" content="20140105" />
<meta http-equiv="Content-Language" content="en" />
</head>
@@ -101,10 +101,13 @@
<li class="none">
<a href="field_types.html" title="Types of Fields">Types of Fields</a>
</li>
- <li class="expanded">
+ <li class="expanded">
<a href="metadata.html" title="MetaData">MetaData</a>
<ul>
<li class="none">
+ <a href="annotations.html" title="Annotations">Annotations</a>
+ </li>
+ <li class="none">
<a href="jdo_dtd.html" title="jdo DTD/XSD">jdo DTD/XSD</a>
</li>
<li class="none">
@@ -223,45 +226,45 @@
</div>
<div id="bodyColumn">
<div id="contentBox">
-
-
- <div class="section"><h2>Meta-Data - JDOQuery<a name="Meta-Data_-_JDOQuery"></a></h2>
- <p>
- JDO2 defines XML MetaData in <b>jdo</b> files as well as <b>orm</b> files, but also
- specifies that named queries can be defined in <i>jdoquery</i> files.
- As always with XML, the metadata must match the defined DTD/XSD for that file type.
- This section describes the content of the <b>jdoquery</b> files.
- All <b>jdoquery</b> files must contain a valid DTD/DOCTYPE specification.
- You can use PUBLIC or SYSTEM versions of these.
- </p>
- <p>
- Here are a few examples valid for <b>jdoquery</b> files eith DTD specification
- </p>
- <div class="source"><pre>
-<!DOCTYPE jdoquery PUBLIC
- "-//Sun Microsystems, Inc.//DTD Java Data Objects Query Metadata 3.0//EN"
- "http://java.sun.com/dtd/jdoquery_3_0.dtd">
-
-
-<!DOCTYPE jdoquery SYSTEM "file:/javax/jdo/jdoquery.dtd"></pre></div>
- <br />
- <p>
- Here is an example valid for <b>jdoquery</b> files with XSD specification
- </p>
- <div class="source"><pre>
-<?xml version="1.0" encoding="UTF-8" ?>
-<jdo xmlns="http://java.sun.com/xml/ns/jdo/jdo"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/jdo/jdoquery
- http://java.sun.com/xml/ns/jdo/jdoquery_3_0.xsd">
- ...
-</jdo></pre></div>
- <p>
- Your MetaData should match either the <a class="externalLink" href="http://java.sun.com/dtd/jdoquery_3_0.dtd" target="_blank">DTD</a>
- or the <a class="externalLink" href="http://java.sun.com/xml/ns/jdo/jdoquery_3_0.xsd" target="_blank">XSD</a> specification.
- </p>
- </div>
-
+
+
+ <div class="section"><h2>Meta-Data - JDOQuery<a name="Meta-Data_-_JDOQuery"></a></h2>
+ <p>
+ JDO2 defines XML MetaData in <b>jdo</b> files as well as <b>orm</b> files, but also
+ specifies that named queries can be defined in <i>jdoquery</i> files.
+ As always with XML, the metadata must match the defined DTD/XSD for that file type.
+ This section describes the content of the <b>jdoquery</b> files.
+ All <b>jdoquery</b> files must contain a valid DTD/DOCTYPE specification.
+ You can use PUBLIC or SYSTEM versions of these.
+ </p>
+ <p>
+ Here are a few examples valid for <b>jdoquery</b> files eith DTD specification
+ </p>
+ <div class="source"><pre>
+<!DOCTYPE jdoquery PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Java Data Objects Query Metadata 3.0//EN"
+ "http://java.sun.com/dtd/jdoquery_3_0.dtd">
+
+
+<!DOCTYPE jdoquery SYSTEM "file:/javax/jdo/jdoquery.dtd"></pre></div>
+ <br />
+ <p>
+ Here is an example valid for <b>jdoquery</b> files with XSD specification
+ </p>
+ <div class="source"><pre>
+<?xml version="1.0" encoding="UTF-8" ?>
+<jdo xmlns="http://java.sun.com/xml/ns/jdo/jdo"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/jdo/jdoquery
+ http://java.sun.com/xml/ns/jdo/jdoquery_3_0.xsd">
+ ...
+</jdo></pre></div>
+ <p>
+ Your MetaData should match either the <a class="externalLink" href="http://java.sun.com/dtd/jdoquery_3_0.dtd" target="_blank">DTD</a>
+ or the <a class="externalLink" href="http://java.sun.com/xml/ns/jdo/jdoquery_3_0.xsd" target="_blank">XSD</a> specification.
+ </p>
+ </div>
+
</div>
</div>
@@ -270,7 +273,7 @@
</div>
<div id="footer">
<div class="xright">
- Copyright © 2005-2013.
+ Copyright © 2005-2014.
All Rights Reserved.
</div>
Modified: websites/production/db/content/jdo/mail-lists.html
==============================================================================
--- websites/production/db/content/jdo/mail-lists.html (original)
+++ websites/production/db/content/jdo/mail-lists.html Sun Jan 5 10:08:45 2014
@@ -1,5 +1,5 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<!-- Generated by Apache Maven Doxia Site Renderer 1.3 at Nov 4, 2013 -->
+<!-- Generated by Apache Maven Doxia Site Renderer 1.3 at Jan 5, 2014 -->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
@@ -12,7 +12,7 @@
</style>
<link rel="stylesheet" href="./css/print.css" type="text/css" media="print" />
<meta name="author" content="JDO Documentation Team" />
- <meta name="Date-Revision-yyyymmdd" content="20131104" />
+ <meta name="Date-Revision-yyyymmdd" content="20140105" />
<meta http-equiv="Content-Language" content="en" />
</head>
@@ -102,7 +102,7 @@
<li class="none">
<a href="field_types.html" title="Types of Fields">Types of Fields</a>
</li>
- <li class="collapsed">
+ <li class="collapsed">
<a href="metadata.html" title="MetaData">MetaData</a>
</li>
<li class="none">
@@ -210,88 +210,88 @@
</div>
<div id="bodyColumn">
<div id="contentBox">
- <!-- Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements. See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
-the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License. -->
-
-<div class="section"><h2>Apache JDO Mailing Lists<a name="Apache_JDO_Mailing_Lists"></a></h2>
-
-<p>
-There are several publicly available mailing lists for JDO.
-The user list is for general discussion of the Apache JDO project and JDO technology.
-The dev list is for internal discussion among the JDO developers. It is
-open to the public if you are interested in seeing how the sausage is made.
-For those dedicated to the project who want to follow its development even more
-closely there's the commits mailing list!
-</p>
-
-<table border="0" class="bodyTable">
-<tr class="a">
-<td>
-<p><b>User List</b> : <a class="externalLink" href="mailto:jdo-user@db.apache.org">
- jdo-user@db.apache.org</a> </p>
-</td>
-<td>
-<p> <a class="external" href="mailto:jdo-user-subscribe@db.apache.org" rel="nofollow">
- Subscribe</a> </p>
-</td>
-<td>
-<p> <a class="external" href="mailto:jdo-user-unsubscribe@db.apache.org" rel="nofollow">
- Unsubscribe</a> </p>
-</td>
-<td>
-<p>
-<a class="externalLink" href="http://mail-archives.apache.org/mod_mbox/db-jdo-user/">Archive</a>
-</p>
-</td>
-</tr>
-<tr class="b">
-<td>
-<p><b>Dev List</b> : <a class="externalLink" href="mailto:jdo-dev@db.apache.org"> jdo-dev@db.apache.org</a> </p>
-</td>
-<td>
-<p> <a class="external" href="mailto:jdo-dev-subscribe@db.apache.org" rel="nofollow"> Subscribe</a> </p>
-</td>
-<td>
-<p> <a class="external" href="mailto:jdo-dev-unsubscribe@db.apache.org" rel="nofollow"> Unsubscribe</a> </p>
-</td>
-<td>
-<p>
-<a class="externalLink" href="http://mail-archives.apache.org/mod_mbox/db-jdo-dev/">Archive</a>
-</p>
-</td>
-</tr>
-<tr class="a">
-<td>
-<p><b>Commits List</b> : <a class="externalLink" href="mailto:jdo-commits@db.apache.org">jdo-commits@db.apache.org</a> </p>
-</td>
-<td>
-<p> <a class="external" href="mailto:jdo-commits-subscribe@db.apache.org" rel="nofollow">Subscribe</a> </p>
-</td>
-<td>
-<p> <a class="external" href="mailto:jdo-commits-unsubscribe@db.apache.org" rel="nofollow">Unsubscribe</a> </p>
-</td>
-<td>
-<p>
-<a class="externalLink" href="http://mail-archives.apache.org/mod_mbox/db-jdo-commits/">Archive</a>
-</p>
-</td>
-</tr>
-</table>
-
-</div>
-
+ <!-- Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License. -->
+
+<div class="section"><h2>Apache JDO Mailing Lists<a name="Apache_JDO_Mailing_Lists"></a></h2>
+
+<p>
+There are several publicly available mailing lists for JDO.
+The user list is for general discussion of the Apache JDO project and JDO technology.
+The dev list is for internal discussion among the JDO developers. It is
+open to the public if you are interested in seeing how the sausage is made.
+For those dedicated to the project who want to follow its development even more
+closely there's the commits mailing list!
+</p>
+
+<table border="0" class="bodyTable">
+<tr class="a">
+<td>
+<p><b>User List</b> : <a class="externalLink" href="mailto:jdo-user@db.apache.org">
+ jdo-user@db.apache.org</a> </p>
+</td>
+<td>
+<p> <a class="external" href="mailto:jdo-user-subscribe@db.apache.org" rel="nofollow">
+ Subscribe</a> </p>
+</td>
+<td>
+<p> <a class="external" href="mailto:jdo-user-unsubscribe@db.apache.org" rel="nofollow">
+ Unsubscribe</a> </p>
+</td>
+<td>
+<p>
+<a class="externalLink" href="http://mail-archives.apache.org/mod_mbox/db-jdo-user/">Archive</a>
+</p>
+</td>
+</tr>
+<tr class="b">
+<td>
+<p><b>Dev List</b> : <a class="externalLink" href="mailto:jdo-dev@db.apache.org"> jdo-dev@db.apache.org</a> </p>
+</td>
+<td>
+<p> <a class="external" href="mailto:jdo-dev-subscribe@db.apache.org" rel="nofollow"> Subscribe</a> </p>
+</td>
+<td>
+<p> <a class="external" href="mailto:jdo-dev-unsubscribe@db.apache.org" rel="nofollow"> Unsubscribe</a> </p>
+</td>
+<td>
+<p>
+<a class="externalLink" href="http://mail-archives.apache.org/mod_mbox/db-jdo-dev/">Archive</a>
+</p>
+</td>
+</tr>
+<tr class="a">
+<td>
+<p><b>Commits List</b> : <a class="externalLink" href="mailto:jdo-commits@db.apache.org">jdo-commits@db.apache.org</a> </p>
+</td>
+<td>
+<p> <a class="external" href="mailto:jdo-commits-subscribe@db.apache.org" rel="nofollow">Subscribe</a> </p>
+</td>
+<td>
+<p> <a class="external" href="mailto:jdo-commits-unsubscribe@db.apache.org" rel="nofollow">Unsubscribe</a> </p>
+</td>
+<td>
+<p>
+<a class="externalLink" href="http://mail-archives.apache.org/mod_mbox/db-jdo-commits/">Archive</a>
+</p>
+</td>
+</tr>
+</table>
+
+</div>
+
</div>
</div>
@@ -300,7 +300,7 @@ closely there's the commits mailing list
</div>
<div id="footer">
<div class="xright">
- Copyright © 2005-2013.
+ Copyright © 2005-2014.
All Rights Reserved.
</div>