Modified: websites/production/db/content/jdo/metadata.html ============================================================================== --- websites/production/db/content/jdo/metadata.html (original) +++ websites/production/db/content/jdo/metadata.html Mon Jan 21 04:23:17 2013 @@ -1,9 +1,9 @@ <!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 Jan 16, 2013 --> +<!-- Generated by Apache Maven Doxia Site Renderer 1.3 at Jan 20, 2013 --> <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" /> - <title>Maven - + <title>JDO - JDO MetaData</title> <style type="text/css" media="all"> @import url("./css/maven-base.css"); @@ -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="20130116" /> + <meta name="Date-Revision-yyyymmdd" content="20130120" /> <meta http-equiv="Content-Language" content="en" /> </head> @@ -30,7 +30,13 @@ <div id="breadcrumbs"> - <div class="xright"> <a href="http://wiki.apache.org/jdo" class="externalLink" title="Wiki">Wiki</a> + <div class="xright"> <a href="https://www.facebook.com/JavaDataObjects" class="externalLink" title="Facebook">Facebook</a> + | + <a href="https://twitter.com/JavaDataObjects" class="externalLink" title="Twitter">Twitter</a> + | + <a href="https://plus.google.com/106584233526334524963" class="externalLink" title="Google+">Google+</a> + | + <a href="http://wiki.apache.org/jdo" class="externalLink" title="Wiki">Wiki</a> | <a href="http://issues.apache.org/jira/secure/BrowseProject.jspa?id=10630" class="externalLink" title="Issue Tracker">Issue Tracker</a> | @@ -217,57 +223,57 @@ </div> <div id="bodyColumn"> <div id="contentBox"> - - - <div class="section"><h2>Persistence MetaData<a name="Persistence_MetaData"></a></h2> - <p> - 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. - </p> - <div class="section"><h3>XML MetaData<a name="XML_MetaData"></a></h3> - <p> - 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 - <i>com.mycompany.sample.MyExample</i>, JDO will look for any of the following files - until it finds one (in the order stated) :- - </p> - <div class="source"><pre> -META-INF/package.jdo -WEB-INF/package.jdo -package.jdo -com/package.jdo -com/mycompany/package.jdo -com/mycompany/sample/package.jdo -com/mycompany/sample/MyExample.jdo</pre></div> - <p> - In addition to specifying XML MetaData in a <b>jdo</b> 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. - </p> - <div class="source"><pre> -META-INF/package-{mapping}.orm -WEB-INF/package-{mapping}.orm -package-{mapping}.orm -com/package-{mapping}.orm -com/mycompany/package-{mapping}.orm -com/mycompany/sample/package-{mapping}.orm -com/mycompany/sample/MyExample-{mapping}.orm</pre></div> - <p> - where <i>{mapping}</i> 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. - </p> - <br /> - </div> - - <div class="section"><h3>Annotations<a name="Annotations"></a></h3> - <p> - JDO 2.1 provides support for annotations. Classes and fields/properties can be annotated - defining the persistence and, optionally, any ORM information. - </p> - </div> - </div> - + + + <div class="section"><h2>Persistence MetaData<a name="Persistence_MetaData"></a></h2> + <p> + 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. + </p> + <div class="section"><h3>XML MetaData<a name="XML_MetaData"></a></h3> + <p> + 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 + <i>com.mycompany.sample.MyExample</i>, JDO will look for any of the following files + until it finds one (in the order stated) :- + </p> + <div class="source"><pre> +META-INF/package.jdo +WEB-INF/package.jdo +package.jdo +com/package.jdo +com/mycompany/package.jdo +com/mycompany/sample/package.jdo +com/mycompany/sample/MyExample.jdo</pre></div> + <p> + In addition to specifying XML MetaData in a <b>jdo</b> 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. + </p> + <div class="source"><pre> +META-INF/package-{mapping}.orm +WEB-INF/package-{mapping}.orm +package-{mapping}.orm +com/package-{mapping}.orm +com/mycompany/package-{mapping}.orm +com/mycompany/sample/package-{mapping}.orm +com/mycompany/sample/MyExample-{mapping}.orm</pre></div> + <p> + where <i>{mapping}</i> 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. + </p> + <br /> + </div> + + <div class="section"><h3>Annotations<a name="Annotations"></a></h3> + <p> + JDO 2.1 provides support for annotations. Classes and fields/properties can be annotated + defining the persistence and, optionally, any ORM information. + </p> + </div> + </div> + </div> </div>
Modified: websites/production/db/content/jdo/newshistory.html ============================================================================== --- websites/production/db/content/jdo/newshistory.html (original) +++ websites/production/db/content/jdo/newshistory.html Mon Jan 21 04:23:17 2013 @@ -1,9 +1,9 @@ <!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 Jan 16, 2013 --> +<!-- Generated by Apache Maven Doxia Site Renderer 1.3 at Jan 20, 2013 --> <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" /> - <title>Maven - + <title>JDO - News</title> <style type="text/css" media="all"> @import url("./css/maven-base.css"); @@ -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="20130116" /> + <meta name="Date-Revision-yyyymmdd" content="20130120" /> <meta http-equiv="Content-Language" content="en" /> </head> @@ -31,7 +31,13 @@ <div id="breadcrumbs"> - <div class="xright"> <a href="http://wiki.apache.org/jdo" class="externalLink" title="Wiki">Wiki</a> + <div class="xright"> <a href="https://www.facebook.com/JavaDataObjects" class="externalLink" title="Facebook">Facebook</a> + | + <a href="https://twitter.com/JavaDataObjects" class="externalLink" title="Twitter">Twitter</a> + | + <a href="https://plus.google.com/106584233526334524963" class="externalLink" title="Google+">Google+</a> + | + <a href="http://wiki.apache.org/jdo" class="externalLink" title="Wiki">Wiki</a> | <a href="http://issues.apache.org/jira/secure/BrowseProject.jspa?id=10630" class="externalLink" title="Issue Tracker">Issue Tracker</a> | @@ -204,41 +210,41 @@ </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>Older JDO News<a name="Older_JDO_News"></a></h2> - -<p> -<b>JDO code donated to Apache by Sun Microsystems, Inc.</b> -</p> -<p>On 9-Mar-2005 Sun Microsystems, Inc. officially donated -to Apache Software Foundation the -intellectual property known as Java Data Objects, v. 1.0.2 and -successors thereto to the extent provided by Sun. -</p> -<p> -This was accomplished via Schedule B-2 to the Software Grant and -Corporate Contributor License Agreement (CCLA) between -The Apache Software Foundation and Sun Microsystems, Inc. -</p> - </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>Older JDO News<a name="Older_JDO_News"></a></h2> + +<p> +<b>JDO code donated to Apache by Sun Microsystems, Inc.</b> +</p> +<p>On 9-Mar-2005 Sun Microsystems, Inc. officially donated +to Apache Software Foundation the +intellectual property known as Java Data Objects, v. 1.0.2 and +successors thereto to the extent provided by Sun. +</p> +<p> +This was accomplished via Schedule B-2 to the Software Grant and +Corporate Contributor License Agreement (CCLA) between +The Apache Software Foundation and Sun Microsystems, Inc. +</p> + </div> + + </div> </div> Modified: websites/production/db/content/jdo/object_retrieval.html ============================================================================== --- websites/production/db/content/jdo/object_retrieval.html (original) +++ websites/production/db/content/jdo/object_retrieval.html Mon Jan 21 04:23:17 2013 @@ -1,9 +1,9 @@ <!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 Jan 16, 2013 --> +<!-- Generated by Apache Maven Doxia Site Renderer 1.3 at Jan 20, 2013 --> <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" /> - <title>Maven - + <title>JDO - JDO Object Retrieval</title> <style type="text/css" media="all"> @import url("./css/maven-base.css"); @@ -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="20130116" /> + <meta name="Date-Revision-yyyymmdd" content="20130120" /> <meta http-equiv="Content-Language" content="en" /> </head> @@ -30,7 +30,13 @@ <div id="breadcrumbs"> - <div class="xright"> <a href="http://wiki.apache.org/jdo" class="externalLink" title="Wiki">Wiki</a> + <div class="xright"> <a href="https://www.facebook.com/JavaDataObjects" class="externalLink" title="Facebook">Facebook</a> + | + <a href="https://twitter.com/JavaDataObjects" class="externalLink" title="Twitter">Twitter</a> + | + <a href="https://plus.google.com/106584233526334524963" class="externalLink" title="Google+">Google+</a> + | + <a href="http://wiki.apache.org/jdo" class="externalLink" title="Wiki">Wiki</a> | <a href="http://issues.apache.org/jira/secure/BrowseProject.jspa?id=10630" class="externalLink" title="Issue Tracker">Issue Tracker</a> | @@ -203,82 +209,82 @@ </div> <div id="bodyColumn"> <div id="contentBox"> - - - <div class="section"><h2>Object Retrieval<a name="Object_Retrieval"></a></h2> - <p> - JDO provides persistence of objects. The logical next step after persisting - objects is to retrieve them for use in your application. - There are several ways to do this - </p> - - <div class="section"><h3>Retrieve an object from its identity<a name="Retrieve_an_object_from_its_identity"></a></h3> - <p> - The simplest form of object retrieval is where we have the identity. - This is simply - </p> - <div class="source"><pre> -Object obj = pm.getObjectById(identity); - </pre></div> - <p> - If the object is in the JDO cache then it is retrieved from there, - otherwise the JDO implementation goes to the datastore. When the object - is retrieved its fields are populated according to its Fetch Group. - </p> - </div> - - <div class="section"><h3>Retrieve an object based on its Extent<a name="Retrieve_an_object_based_on_its_Extent"></a></h3> - <p> - A persistable class can be persisted with an <b>Extent</b> of all - instances of that type. - You can use this to retrieve objects of the required type, like this - </p> - <div class="source"><pre> -Extent ex = pm.getExtent(MyClass.class, true); -Iterator iter = ex.iterator(); -while (iter.hasNext()) -{ - MyClass obj = (MyClass)iter.next(); - ... -}</pre></div> - <p> - The second argument in the <i>getExtent</i> call is whether to include - instances of subclasses. - </p> - <br /> - </div> - - <div class="section"><h3>Retrieve an object based on a criteria<a name="Retrieve_an_object_based_on_a_criteria"></a></h3> - <p> - Where we want to retrieve all objects based on some criteria (e.g all - objects of class A where field 'x' of A is a certain value) we need to - use a query language. JDO2 provides 2 options here. JDOQL is object-based - and allows you to express your query in terms of the classes and fields - you are using. SQL is datastore-based and allows you to express your query - in terms of the datastore tables and columns. - </p> - <p> - To give an example of a JDOQL query - </p> - <div class="source"><pre> -Query q = pm.newQuery(MyClass.class, "field1 < value"); -q.declareParameters("int value"); -List results = q.execute(205); -Iterator iter = results.iterator(); -while (iter.hasNext()) -{ - MyClass obj = (MyClass)iter.next(); -}</pre></div> - <p> - If the objects found by the query are in the JDO cache then they are - retrieved from there, otherwise the JDO implementation goes to the - datastore. When the objects are retrieved their fields are populated - according to the Fetch Group. - </p> - </div> - </div> - - + + + <div class="section"><h2>Object Retrieval<a name="Object_Retrieval"></a></h2> + <p> + JDO provides persistence of objects. The logical next step after persisting + objects is to retrieve them for use in your application. + There are several ways to do this + </p> + + <div class="section"><h3>Retrieve an object from its identity<a name="Retrieve_an_object_from_its_identity"></a></h3> + <p> + The simplest form of object retrieval is where we have the identity. + This is simply + </p> + <div class="source"><pre> +Object obj = pm.getObjectById(identity); + </pre></div> + <p> + If the object is in the JDO cache then it is retrieved from there, + otherwise the JDO implementation goes to the datastore. When the object + is retrieved its fields are populated according to its Fetch Group. + </p> + </div> + + <div class="section"><h3>Retrieve an object based on its Extent<a name="Retrieve_an_object_based_on_its_Extent"></a></h3> + <p> + A persistable class can be persisted with an <b>Extent</b> of all + instances of that type. + You can use this to retrieve objects of the required type, like this + </p> + <div class="source"><pre> +Extent ex = pm.getExtent(MyClass.class, true); +Iterator iter = ex.iterator(); +while (iter.hasNext()) +{ + MyClass obj = (MyClass)iter.next(); + ... +}</pre></div> + <p> + The second argument in the <i>getExtent</i> call is whether to include + instances of subclasses. + </p> + <br /> + </div> + + <div class="section"><h3>Retrieve an object based on a criteria<a name="Retrieve_an_object_based_on_a_criteria"></a></h3> + <p> + Where we want to retrieve all objects based on some criteria (e.g all + objects of class A where field 'x' of A is a certain value) we need to + use a query language. JDO2 provides 2 options here. JDOQL is object-based + and allows you to express your query in terms of the classes and fields + you are using. SQL is datastore-based and allows you to express your query + in terms of the datastore tables and columns. + </p> + <p> + To give an example of a JDOQL query + </p> + <div class="source"><pre> +Query q = pm.newQuery(MyClass.class, "field1 < value"); +q.declareParameters("int value"); +List results = q.execute(205); +Iterator iter = results.iterator(); +while (iter.hasNext()) +{ + MyClass obj = (MyClass)iter.next(); +}</pre></div> + <p> + If the objects found by the query are in the JDO cache then they are + retrieved from there, otherwise the JDO implementation goes to the + datastore. When the objects are retrieved their fields are populated + according to the Fetch Group. + </p> + </div> + </div> + + </div> </div> Modified: websites/production/db/content/jdo/orm_dtd.html ============================================================================== --- websites/production/db/content/jdo/orm_dtd.html (original) +++ websites/production/db/content/jdo/orm_dtd.html Mon Jan 21 04:23:17 2013 @@ -1,9 +1,9 @@ <!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 Jan 16, 2013 --> +<!-- Generated by Apache Maven Doxia Site Renderer 1.3 at Jan 20, 2013 --> <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" /> - <title>Maven - + <title>JDO - ORM DTD</title> <style type="text/css" media="all"> @import url("./css/maven-base.css"); @@ -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="20130116" /> + <meta name="Date-Revision-yyyymmdd" content="20130120" /> <meta http-equiv="Content-Language" content="en" /> </head> @@ -30,7 +30,13 @@ <div id="breadcrumbs"> - <div class="xright"> <a href="http://wiki.apache.org/jdo" class="externalLink" title="Wiki">Wiki</a> + <div class="xright"> <a href="https://www.facebook.com/JavaDataObjects" class="externalLink" title="Facebook">Facebook</a> + | + <a href="https://twitter.com/JavaDataObjects" class="externalLink" title="Twitter">Twitter</a> + | + <a href="https://plus.google.com/106584233526334524963" class="externalLink" title="Google+">Google+</a> + | + <a href="http://wiki.apache.org/jdo" class="externalLink" title="Wiki">Wiki</a> | <a href="http://issues.apache.org/jira/secure/BrowseProject.jspa?id=10630" class="externalLink" title="Issue Tracker">Issue Tracker</a> | @@ -217,45 +223,45 @@ </div> <div id="bodyColumn"> <div id="contentBox"> - - - <div class="section"><h2>Meta-Data - ORM<a name="Meta-Data_-_ORM"></a></h2> - <p> - JDO defines XML MetaData in <b>jdo</b> files as well as <b>orm</b> 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>orm</b> files. - The content of <b>jdo</b> files can be found <a href="jdo_dtd.html">here</a>. - All <b>orm</b> files must contain a valid DTD/DOCTYPE specification. You can use PUBLIC or SYSTEM versions of these. - </p> - <p> - Here are a couple of examples valid for <b>orm</b> files with DTD specification - </p> - <div class="source"><pre> -<!DOCTYPE orm PUBLIC - "-//Sun Microsystems, Inc.//DTD Java Data Objects Mapping Metadata 3.0//EN" - "http://java.sun.com/dtd/orm_3_0.dtd"> - - -<!DOCTYPE orm SYSTEM "file:/javax/jdo/orm.dtd"></pre></div> - <br /> - <p> - Here is an example valid for <b>orm</b> files with XSD specification - </p> - <div class="source"><pre> -<?xml version="1.0" encoding="UTF-8" ?> -<orm xmlns="http://java.sun.com/xml/ns/jdo/orm" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://java.sun.com/xml/ns/jdo/orm - http://java.sun.com/xml/ns/jdo/orm_3_0.xsd"> - ... -</orm></pre></div> - <p> - Your MetaData should match either the <a class="externalLink" href="http://java.sun.com/dtd/orm_3_0.dtd" target="_blank">DTD</a> - or the <a class="externalLink" href="http://java.sun.com/xml/ns/jdo/orm_3_0.xsd" target="_blank">XSD</a> specification. - </p> - - </div> - + + + <div class="section"><h2>Meta-Data - ORM<a name="Meta-Data_-_ORM"></a></h2> + <p> + JDO defines XML MetaData in <b>jdo</b> files as well as <b>orm</b> 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>orm</b> files. + The content of <b>jdo</b> files can be found <a href="jdo_dtd.html">here</a>. + All <b>orm</b> files must contain a valid DTD/DOCTYPE specification. You can use PUBLIC or SYSTEM versions of these. + </p> + <p> + Here are a couple of examples valid for <b>orm</b> files with DTD specification + </p> + <div class="source"><pre> +<!DOCTYPE orm PUBLIC + "-//Sun Microsystems, Inc.//DTD Java Data Objects Mapping Metadata 3.0//EN" + "http://java.sun.com/dtd/orm_3_0.dtd"> + + +<!DOCTYPE orm SYSTEM "file:/javax/jdo/orm.dtd"></pre></div> + <br /> + <p> + Here is an example valid for <b>orm</b> files with XSD specification + </p> + <div class="source"><pre> +<?xml version="1.0" encoding="UTF-8" ?> +<orm xmlns="http://java.sun.com/xml/ns/jdo/orm" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/jdo/orm + http://java.sun.com/xml/ns/jdo/orm_3_0.xsd"> + ... +</orm></pre></div> + <p> + Your MetaData should match either the <a class="externalLink" href="http://java.sun.com/dtd/orm_3_0.dtd" target="_blank">DTD</a> + or the <a class="externalLink" href="http://java.sun.com/xml/ns/jdo/orm_3_0.xsd" target="_blank">XSD</a> specification. + </p> + + </div> + </div> </div> Modified: websites/production/db/content/jdo/pm.html ============================================================================== --- websites/production/db/content/jdo/pm.html (original) +++ websites/production/db/content/jdo/pm.html Mon Jan 21 04:23:17 2013 @@ -1,9 +1,9 @@ <!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 Jan 16, 2013 --> +<!-- Generated by Apache Maven Doxia Site Renderer 1.3 at Jan 20, 2013 --> <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" /> - <title>Maven - + <title>JDO - Persistence Manager</title> <style type="text/css" media="all"> @import url("./css/maven-base.css"); @@ -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="20130116" /> + <meta name="Date-Revision-yyyymmdd" content="20130120" /> <meta http-equiv="Content-Language" content="en" /> </head> @@ -30,7 +30,13 @@ <div id="breadcrumbs"> - <div class="xright"> <a href="http://wiki.apache.org/jdo" class="externalLink" title="Wiki">Wiki</a> + <div class="xright"> <a href="https://www.facebook.com/JavaDataObjects" class="externalLink" title="Facebook">Facebook</a> + | + <a href="https://twitter.com/JavaDataObjects" class="externalLink" title="Twitter">Twitter</a> + | + <a href="https://plus.google.com/106584233526334524963" class="externalLink" title="Google+">Google+</a> + | + <a href="http://wiki.apache.org/jdo" class="externalLink" title="Wiki">Wiki</a> | <a href="http://issues.apache.org/jira/secure/BrowseProject.jspa?id=10630" class="externalLink" title="Issue Tracker">Issue Tracker</a> | @@ -203,212 +209,212 @@ </div> <div id="bodyColumn"> <div id="contentBox"> - - - <div class="section"><h2>Persistence Manager<a name="Persistence_Manager"></a></h2> - <p> - Any JDO-enabled application will require at least one <i>PersistenceManager</i> (PM). - This is obtained from the <a href="pmf.html">PersistenceManagerFactory</a> for the datastore. - </p> - <p> - The simplest way of creating a <i>PersistenceManager</i> - <a href="api20/apidocs/javax/jdo/PersistenceManager.html" target="_blank"><img src="images/javadoc.gif" alt="" /></a> - is as follows - </p> - <div class="source"><pre> -PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory(props); -PersistenceManager pm = pmf.getPersistenceManager();</pre></div> - <p> - A <i>PersistenceManager</i> is the key to all persistence operations in JDO. With it you can - persist, update, delete, and retrieve objects from the datastore. A <i>PersistenceManager</i> - has a single transaction. - </p> - <br /> - - <div class="section"><h3>Persist Objects<a name="Persist_Objects"></a></h3> - <p> - To persist an object, the object must first be marked as persistable using - <a href="metadata.html">MetaData (XML/Annotations)</a>. Then you would start the - PM transaction, and use <i>makePersistent</i> as follows - </p> - <div class="source"><pre> -PersistenceManager pm = pmf.getPersistenceManager(); -Transaction tx = pm.currentTransaction(); -try -{ - // Start the transaction - tx.begin(); - - // Create the object to persist - MyClass obj = new MyClass(); - - // Persist it to the datastore - pm.makePersistent(obj); - - // Commit the transaction, flushing the object to the datastore - tx.commit(); -} -catch (Exception e) -{ - ... handle exceptions -} -finally -{ - if (tx.isActive()) - { - // Error occurred so rollback the transaction - tx.rollback(); - } - pm.close(); -}</pre></div> - <p> - The <i>makePersistent</i> method of <b>PersistenceManager</b> makes the object persistent in - the datastore, and updates the 'state' of the object from <i>Transient</i> (at the start) - to <i>Hollow</i> (after commit() of the transaction). - </p> - <p> - When an object is persisted, if it has any other objects referenced from that object they - also will be made persistent. This is referred to as <b>persistence-by-reachability</b>. - The main benefit of this is that if you have an object graph to persist, then you don't - need to call <i>makePersistent()</i> on all objects, instead just using one that can be - used to find all of the others. <b>persistence-by-reachability</b> is also run at the time of - calling <i>commit()</i> on the transaction. This has the effect that if you had called - <i>makePersistent()</i> on an object and that had persisted another object, and before - commit you had removed the relation to this other object, then at <i>commit()</i> the - reachability algorithm will find that this other object is no longer reachable and will - remove it from persistence. - </p> - <br /> - </div> - - <div class="section"><h3>Retrieve Objects<a name="Retrieve_Objects"></a></h3> - <p> - So we've made some of our objects persistent, and now we want to retrieve them in - our application. Here's one way of retrieving objects of a particular type. - </p> - <div class="source"><pre> -tx = pm.currentTransaction(); -try -{ - tx.begin(); - - Extent e = pm.getExtent(mydomain.MyClass.class, true); - Iterator iter=e.iterator(); - while (iter.hasNext()) - { - MyClass my_obj=(MyClass)iter.next(); - ... - } - - tx.commit(); -} -catch (Exception e) -{ - if (tx.isActive()) - { - tx.rollback(); - } -}</pre></div> - <p> - The <b>Extent</b> interface is one of the ways to retrieve your objects. - The others use the <b>Query</b> interface, allowing more precise filtering over the - objects returned. - </p> - <br /> - </div> - - <div class="section"><h3>Update Objects<a name="Update_Objects"></a></h3> - <p> - To update an object we firstly retrieve it, as above, and then we call any of its - mutator methods. For example - </p> - <div class="source"><pre> -tx = pm.currentTransaction(); -try -{ - tx.begin(); - - Extent e = pm.getExtent(mydomain.MyClass.class, true); - Iterator iter=e.iterator(); - while (iter.hasNext()) - { - MyClass my_obj=(MyClass)iter.next(); - my_obj.setValue(25.0); // Change the value - ... - } - - tx.commit(); -} -catch (Exception e) -{ - if (tx.isActive()) - { - tx.rollback(); - } -}</pre></div> - <p> - When <i>setValue()</i> is called on the persistent object this change is intercepted - by JDO and the value change will be automatically sent to the datastore ... transparently! - </p> - <br /> - </div> - - <div class="section"><h3>Delete Objects<a name="Delete_Objects"></a></h3> - <p> - So we can persist objects, and retrieve them. Now we want to remove one from persistence. - </p> - <div class="source"><pre>try -{ - tx = pm.currentTransaction(); - tx.begin(); - - ... (code to retrieve object in question) ... - - pm.deletePersistent(my_obj); - - tx.commit(); -} -catch (Exception e) -{ - if (tx.isActive()) - { - tx.rollback(); - } -}</pre></div> - <br /> - </div> - - <div class="section"><h3>Making an object transient<a name="Making_an_object_transient"></a></h3> - <p> - As we have seen in the <a href="state_transition.html">JDO States guide</a>, an object can - have many possible states. When we want to take an object and work on it, but removing - its identity we can make it <b>transient</b>. This means that it will retain the values - of its fields, yet will no longer be associated with the object in the datastore. - We do this as follows - </p> - <div class="source"><pre>try -{ - tx = pm.currentTransaction(); - tx.begin(); - - ... (code to retrieve object in question) ... - - pm.makeTransient(my_obj); - - tx.commit(); -} -catch (Exception e) -{ - if (tx.isActive()) - { - tx.rollback(); - } -} - -... (code to work on "my_obj")</pre></div> - </div> - </div> - + + + <div class="section"><h2>Persistence Manager<a name="Persistence_Manager"></a></h2> + <p> + Any JDO-enabled application will require at least one <i>PersistenceManager</i> (PM). + This is obtained from the <a href="pmf.html">PersistenceManagerFactory</a> for the datastore. + </p> + <p> + The simplest way of creating a <i>PersistenceManager</i> + <a href="api20/apidocs/javax/jdo/PersistenceManager.html" target="_blank"><img src="images/javadoc.gif" alt="" /></a> + is as follows + </p> + <div class="source"><pre> +PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory(props); +PersistenceManager pm = pmf.getPersistenceManager();</pre></div> + <p> + A <i>PersistenceManager</i> is the key to all persistence operations in JDO. With it you can + persist, update, delete, and retrieve objects from the datastore. A <i>PersistenceManager</i> + has a single transaction. + </p> + <br /> + + <div class="section"><h3>Persist Objects<a name="Persist_Objects"></a></h3> + <p> + To persist an object, the object must first be marked as persistable using + <a href="metadata.html">MetaData (XML/Annotations)</a>. Then you would start the + PM transaction, and use <i>makePersistent</i> as follows + </p> + <div class="source"><pre> +PersistenceManager pm = pmf.getPersistenceManager(); +Transaction tx = pm.currentTransaction(); +try +{ + // Start the transaction + tx.begin(); + + // Create the object to persist + MyClass obj = new MyClass(); + + // Persist it to the datastore + pm.makePersistent(obj); + + // Commit the transaction, flushing the object to the datastore + tx.commit(); +} +catch (Exception e) +{ + ... handle exceptions +} +finally +{ + if (tx.isActive()) + { + // Error occurred so rollback the transaction + tx.rollback(); + } + pm.close(); +}</pre></div> + <p> + The <i>makePersistent</i> method of <b>PersistenceManager</b> makes the object persistent in + the datastore, and updates the 'state' of the object from <i>Transient</i> (at the start) + to <i>Hollow</i> (after commit() of the transaction). + </p> + <p> + When an object is persisted, if it has any other objects referenced from that object they + also will be made persistent. This is referred to as <b>persistence-by-reachability</b>. + The main benefit of this is that if you have an object graph to persist, then you don't + need to call <i>makePersistent()</i> on all objects, instead just using one that can be + used to find all of the others. <b>persistence-by-reachability</b> is also run at the time of + calling <i>commit()</i> on the transaction. This has the effect that if you had called + <i>makePersistent()</i> on an object and that had persisted another object, and before + commit you had removed the relation to this other object, then at <i>commit()</i> the + reachability algorithm will find that this other object is no longer reachable and will + remove it from persistence. + </p> + <br /> + </div> + + <div class="section"><h3>Retrieve Objects<a name="Retrieve_Objects"></a></h3> + <p> + So we've made some of our objects persistent, and now we want to retrieve them in + our application. Here's one way of retrieving objects of a particular type. + </p> + <div class="source"><pre> +tx = pm.currentTransaction(); +try +{ + tx.begin(); + + Extent e = pm.getExtent(mydomain.MyClass.class, true); + Iterator iter=e.iterator(); + while (iter.hasNext()) + { + MyClass my_obj=(MyClass)iter.next(); + ... + } + + tx.commit(); +} +catch (Exception e) +{ + if (tx.isActive()) + { + tx.rollback(); + } +}</pre></div> + <p> + The <b>Extent</b> interface is one of the ways to retrieve your objects. + The others use the <b>Query</b> interface, allowing more precise filtering over the + objects returned. + </p> + <br /> + </div> + + <div class="section"><h3>Update Objects<a name="Update_Objects"></a></h3> + <p> + To update an object we firstly retrieve it, as above, and then we call any of its + mutator methods. For example + </p> + <div class="source"><pre> +tx = pm.currentTransaction(); +try +{ + tx.begin(); + + Extent e = pm.getExtent(mydomain.MyClass.class, true); + Iterator iter=e.iterator(); + while (iter.hasNext()) + { + MyClass my_obj=(MyClass)iter.next(); + my_obj.setValue(25.0); // Change the value + ... + } + + tx.commit(); +} +catch (Exception e) +{ + if (tx.isActive()) + { + tx.rollback(); + } +}</pre></div> + <p> + When <i>setValue()</i> is called on the persistent object this change is intercepted + by JDO and the value change will be automatically sent to the datastore ... transparently! + </p> + <br /> + </div> + + <div class="section"><h3>Delete Objects<a name="Delete_Objects"></a></h3> + <p> + So we can persist objects, and retrieve them. Now we want to remove one from persistence. + </p> + <div class="source"><pre>try +{ + tx = pm.currentTransaction(); + tx.begin(); + + ... (code to retrieve object in question) ... + + pm.deletePersistent(my_obj); + + tx.commit(); +} +catch (Exception e) +{ + if (tx.isActive()) + { + tx.rollback(); + } +}</pre></div> + <br /> + </div> + + <div class="section"><h3>Making an object transient<a name="Making_an_object_transient"></a></h3> + <p> + As we have seen in the <a href="state_transition.html">JDO States guide</a>, an object can + have many possible states. When we want to take an object and work on it, but removing + its identity we can make it <b>transient</b>. This means that it will retain the values + of its fields, yet will no longer be associated with the object in the datastore. + We do this as follows + </p> + <div class="source"><pre>try +{ + tx = pm.currentTransaction(); + tx.begin(); + + ... (code to retrieve object in question) ... + + pm.makeTransient(my_obj); + + tx.commit(); +} +catch (Exception e) +{ + if (tx.isActive()) + { + tx.rollback(); + } +} + +... (code to work on "my_obj")</pre></div> + </div> + </div> + </div> </div>