Return-Path: X-Original-To: apmail-db-general-archive@www.apache.org Delivered-To: apmail-db-general-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9CF6EE729 for ; Tue, 15 Jan 2013 06:30:34 +0000 (UTC) Received: (qmail 39664 invoked by uid 500); 15 Jan 2013 06:30:32 -0000 Delivered-To: apmail-db-general-archive@db.apache.org Received: (qmail 39206 invoked by uid 500); 15 Jan 2013 06:30:29 -0000 Mailing-List: contact general-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: general@db.apache.org List-Id: Delivered-To: mailing list general@db.apache.org Received: (qmail 38834 invoked by uid 99); 15 Jan 2013 06:30:25 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Jan 2013 06:30:25 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Jan 2013 06:29:55 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 09EAD2388C42 for ; Tue, 15 Jan 2013 06:29:07 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r846705 [11/20] - in /websites/production/db/content/jdo: ./ guides/ images/ images/logos/ releases/ Date: Tue, 15 Jan 2013 06:29:02 -0000 To: general@db.apache.org From: andyj@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130115062907.09EAD2388C42@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 Tue Jan 15 06:29:01 2013 @@ -1,79 +1,323 @@ -Java Data Objects (JDO) - JDOQL - Result

JDOQL : Result

+ + + + + + Maven - + JDOQL - Result + + + + + + + +

+ +
+ +
+
+
+ + +

JDOQL : Result

+

As we have seen, a JDOQL query is made up of different parts. In this section we look at the - result part of the query. The result is what we want returning. By default (when not specifying + result 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 result clause. -

    -
  • this - the candidate instance
  • + filter. Firstly let's look at what you can include in the result clause. +

    +
      +
    • this - the candidate instance
    • A field name
    • A variable
    • A parameter (though why you would want a parameter returning is hard to see since you input the value in the first place)
    • An aggregate (count(), avg(), sum(), min(), max())
    • -
    • An expression involving a field (e.g "field1 + 1")
    • -
    • A navigational expression (navigating from one field to another ... e.g "field1.field4")
    • -

    +

  • An expression involving a field (e.g "field1 + 1")
  • +
  • A navigational expression (navigating from one field to another ... e.g "field1.field4")
  • +
+

The result is specified in JDOQL like this

-
query.setResult("count(field1), field2");
-

- In Single-String JDOQL you would specify it directly. -



Result type

- What you specify in the result defines what form of result you get back. -

    -
  • Object - this is returned if you have only a single row in the results and a single +
    query.setResult("count(field1), field2");
    +

    + In Single-String JDOQL you would specify it directly. +

    +
    + +

    Result type

    +

    + What you specify in the result defines what form of result you get back. +

    +
      +
    • Object - 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)")
    • -
    • Object[] - this is returned if you have only a single row in the results, but more - than 1 column (e.g "max(field1), avg(field2)")
    • -
    • List<Object> - 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")
    • -
    • List<Object[]> - 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)")
    • -

    Aggregates

    + (e.g "max(field2)")

  • +
  • Object[] - this is returned if you have only a single row in the results, but more + than 1 column (e.g "max(field1), avg(field2)")
  • +
  • List<Object> - 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")
  • +
  • List<Object[]> - 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)")
  • +
+
+ +

Aggregates

+

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 -

    -
  • avg(val) - returns the average of "val". "val" can be a field, numeric field expression - or "distinct field".
  • -
  • sum(val) - returns the sum of "val". "val" can be a field, numeric field expression, - or "distinct field".
  • -
  • count(val) - returns the count of records of "val". "val" can be a field, or can be - "this", or "distinct field".
  • -
  • min(val) - returns the minimum of "val". "val" can be a field
  • -
  • max(val) - returns the maximum of "val". "val" can be a field
  • -

+

+
    +
  • avg(val) - returns the average of "val". "val" can be a field, numeric field expression + or "distinct field".
  • +
  • sum(val) - returns the sum of "val". "val" can be a field, numeric field expression, + or "distinct field".
  • +
  • count(val) - returns the count of records of "val". "val" can be a field, or can be + "this", or "distinct field".
  • +
  • min(val) - returns the minimum of "val". "val" can be a field
  • +
  • max(val) - returns the maximum of "val". "val" can be a field
  • +
+

So to utilise these you could specify something like

-
-Query q = pm.newQuery("SELECT max(price), min(price) FROM mydomain.Product WHERE status == 1");
-

+

+Query q = pm.newQuery("SELECT max(price), min(price) FROM mydomain.Product WHERE status == 1");
+

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. -



Example - Use of aggregates

+

+
+
+ +

Example - Use of aggregates

+

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". + is a single double precision value being returned via the "result".

-
+                
 Declarative JDOQL :
 Query query = pm.newQuery(mydomain.Product.class);
-query.setFilter("name == \"CD Player\"");
-query.setResult("max(this.price)");
+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\"");
+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();
-


\ No newline at end of file +
+
+ +
+ + + +
+
+
+
+
+ + + 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 Tue Jan 15 06:29:01 2013 @@ -1,36 +1,276 @@ -Java Data Objects (JDO) - JDOQuery DTD

Meta-Data - JDOQuery

- JDO2 defines XML MetaData in jdo files as well as orm files, but also specifies that named queries can be defined in jdoquery files. + + + + + + Maven - + JDOQuery DTD + + + + + + + +

+ +
+ +
+
+
+ + +

Meta-Data - JDOQuery

+

+ JDO2 defines XML MetaData in jdo files as well as orm files, but also + specifies that named queries can be defined in jdoquery files. As always with XML, the metadata must match the defined DTD/XSD for that file type. - This section describes the content of the jdoquery files. - All jdoquery files must contain a valid DTD/DOCTYPE specification. + This section describes the content of the jdoquery files. + All jdoquery files must contain a valid DTD/DOCTYPE specification. You can use PUBLIC or SYSTEM versions of these. -

- Here are a few examples valid for jdoquery files eith DTD specification

-
+            

+ Here are a few examples valid for jdoquery files eith DTD specification +

+
 <!DOCTYPE jdoquery PUBLIC
-    "-//Sun Microsystems, Inc.//DTD Java Data Objects Query Metadata 3.0//EN"
-    "http://java.sun.com/dtd/jdoquery_3_0.dtd">
+    "-//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">
-

- Here is an example valid for jdoquery files with XSD specification +<!DOCTYPE jdoquery SYSTEM "file:/javax/jdo/jdoquery.dtd">

+
+

+ Here is an example valid for jdoquery files with XSD specification

-
-<?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">
+            
+<?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>
-

- Your MetaData should match either the DTD - or the XSD specification. -


\ No newline at end of file +

+ Your MetaData should match either the DTD + or the XSD specification. +

+
+ + +
+
+
+
+
+ + + 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 Tue Jan 15 06:29:01 2013 @@ -1,46 +1,306 @@ -Java Data Objects (JDO) - Mailing Lists

Apache JDO Mailing Lists

+ + + + + + Maven - + Mailing Lists + + + + + + + + +

+ +
+ +
+ +
+
+
+ + + Modified: websites/production/db/content/jdo/metadata.html ============================================================================== --- websites/production/db/content/jdo/metadata.html (original) +++ websites/production/db/content/jdo/metadata.html Tue Jan 15 06:29:01 2013 @@ -1,16 +1,237 @@ -Java Data Objects (JDO) - JDO MetaData

Persistence MetaData

+ + + + + + Maven - + JDO MetaData + + + + + + + +

+ +
+ +
+
+
+ + +

Persistence MetaData

+

JDO 1.0 and JDO 2.0 support specification of persistence using XML MetaData. JDO 2.1 adds on the ability to specify persistence using Java5 annotations. -

XML MetaData

+

+

XML MetaData

+

JDO (1.0.1, 2.0, 2.1) expects any XML MetaData to be specified in a file or files in particular positions in the file system. For example, if you have a class com.mycompany.sample.MyExample, JDO will look for any of the following files until it finds one (in the order stated) :-

-
+                
 META-INF/package.jdo
 WEB-INF/package.jdo
 package.jdo
@@ -18,12 +239,12 @@ com/package.jdo
 com/mycompany/package.jdo
 com/mycompany/sample/package.jdo
 com/mycompany/sample/MyExample.jdo
-

+

In addition to specifying XML MetaData in a jdo file, if defining O/R mapping information you can also split this out into an ORM file. The locations for ORM files are similar in nature to those for JDO files.

-
+                
 META-INF/package-{mapping}.orm
 WEB-INF/package-{mapping}.orm
 package-{mapping}.orm
@@ -31,13 +252,37 @@ com/package-{mapping}.orm
 com/mycompany/package-{mapping}.orm
 com/mycompany/sample/package-{mapping}.orm
 com/mycompany/sample/MyExample-{mapping}.orm
-

- where {mapping} is a property specified by the user and may be "mysql" for - ORM information for MySQL datastores, and "oracle" for ORM information for Oracle +

+ where {mapping} is a property specified by the user and may be "mysql" for + ORM information for MySQL datastores, and "oracle" for ORM information for Oracle datastores, and so on. -



Annotations

+

+
+
+ +

Annotations

+

JDO 2.1 provides support for annotations. Classes and fields/properties can be annotated defining the persistence and, optionally, any ORM information. -


\ No newline at end of file +

+
+
+ + +
+
+
+
+
+ + +