db-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From an...@apache.org
Subject svn commit: r846705 [3/20] - in /websites/production/db/content/jdo: ./ guides/ images/ images/logos/ releases/
Date Tue, 15 Jan 2013 06:29:02 GMT
Modified: websites/production/db/content/jdo/fetchgroups.html
==============================================================================
--- websites/production/db/content/jdo/fetchgroups.html (original)
+++ websites/production/db/content/jdo/fetchgroups.html Tue Jan 15 06:29:01 2013
@@ -1,13 +1,219 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head><title>Java
Data Objects (JDO) - Fetch-Groups</title><style type="text/css" media="all">
-          @import url("./style/maven-base.css");
-          
-			    @import url("./style/maven-theme.css");</style><link rel="stylesheet" href="./style/print.css"
type="text/css" media="print"></link><meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1"></meta></head><body class="composite"><div id="banner"><table><tr><td
nowrap="true"><a href="http://db.apache.org/jdo" id="projectLogo"><img alt="Java
Data Objects (JDO)" src="./images/JDOx120.gif"></img></a><a href="http://db.apache.org/jdo"
id="organizationLogo"><img alt="Java Data Objects (JDO)" src="./images/jdo_text.gif"></img></a></td></tr></table><div
class="clear"><hr></hr></div></div><div id="breadcrumbs"><div
class="xright"></div><div class="clear"><hr></hr></div></div><div
id="leftColumn"><div id="navcolumn"><div id="menuGeneral"><h5>General</h5><ul><li
class="none"><a href="index.html">Home</a></li><li class="none"><a
href="why_jdo.html">Why JDO?</a></li><li class="none"><a href="jdo_v_jpa.html">JDO
v JPA</a></li><li class="none"><a href="jdo_v_jpa_api.htm
 l">JDO v JPA : API</a></li><li class="none"><a href="jdo_v_jpa_orm.html">JDO
v JPA : ORM</a></li><li class="none"><a href="downloads.html">Downloads</a></li><li
class="none"><a href="http://www.apache.org/licenses/LICENSE-2.0" class="externalLink"
title="External Link">License</a></li></ul></div><br></br><div
id="menuJDO_Implementation"><h5>JDO Implementation</h5><ul><li class="none"><a
href="specifications.html">Specifications</a></li><li class="none"><a
href="tck.html">TCK</a></li></ul></div><br></br><div
id="menuJDO_Usage"><h5>JDO Usage</h5><ul><li class="none"><a
href="impls.html">Implementations</a></li><li class="none"><a href="javadoc.html">API
Javadoc</a></li><li class="none"><a href="class_types.html">Types
of Classes</a></li><li class="none"><a href="field_types.html">Types
of Fields</a></li><li class="collapsed"><a href="metadata.html">MetaData</a></li><li
class="none"><a href="enhancement.html">Bytecode Enhancement</a></li><li
class="none"><a href="jdohelper.html
 ">JDOHelper</a></li><li class="none"><a href="pmf.html">PersistenceManagerFactory</a></li><li
class="none"><a href="pm.html">PersistenceManager</a></li><li class="none"><a
href="transactions.html">Transactions</a></li><li class="none"><a
href="attach_detach.html">Attach-Detach</a></li><li class="none"><strong><a
href="fetchgroups.html">Fetch Groups</a></strong></li><li class="none"><a
href="state_transition.html">Object States</a></li><li class="none"><a
href="object_retrieval.html">Object Retrieval</a></li><li class="expanded"><a
href="jdoql.html">JDOQL</a><ul><li class="none"><a href="jdoql_result.html">Result</a></li><li
class="none"><a href="jdoql_methods.html">Methods</a></li><li class="none"><a
href="jdoql_quickref.pdf">Quick Ref PDF</a></li></ul></li><li
class="none"><a href="extents.html">Extents</a></li><li class="collapsed"><a
href="guides.html">Guides</a></li><li class="none"><a href="references.html">References</a></li><li
class="none"><a href="exceptions.html">E
 xceptions</a></li><li class="none"><a href="glossary.html">Glossary</a></li></ul></div><br></br><div
id="menuArticles"><h5>Articles</h5><ul><li class="none"><a href="jdo_3_0_overview.html">JDO
3.0 Overview</a></li></ul></div><br></br><div id="menuCommunity"><h5>Community</h5><ul><li
class="none"><a href="get-involved.html">Get Involved</a></li><li
class="none"><a href="team-list.html">Project Team</a></li><li class="none"><a
href="mail-lists.html">Mailing Lists</a></li><li class="none"><a href="faq.html">FAQ</a></li><li
class="none"><a href="http://wiki.apache.org/jdo" class="externalLink" title="External
Link">Wiki</a></li></ul></div><br></br><div id="menuDevelopment"><h5>Development</h5><ul><li
class="none"><a href="roadmap.html">RoadMap / TODO</a></li><li class="none"><a
href="svn.html">Source Code</a></li><li class="none"><a href="http://cwiki.apache.org/GMOxDEV/coding-standards.html"
class="externalLink" title="External Link">Coding Standards</a></li><li
class="none"><a
  href="issuetracking.html">Issue Tracking</a></li><li class="none"><a
href="dependencies.html">Dependencies</a></li></ul></div><br></br></div></div><div
id="bodyColumn"><div class="contentBox"><div class="section"><a name="Fetch_Groups"></a><h2>Fetch
Groups</h2><p>
+<!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 15, 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 - 
+        Fetch-Groups</title>
+    <style type="text/css" media="all">
+      @import url("./css/maven-base.css");
+      @import url("./css/maven-theme.css");
+      @import url("./css/site.css");
+    </style>
+    <link rel="stylesheet" href="./css/print.css" type="text/css" media="print" />
+    <meta name="Date-Revision-yyyymmdd" content="20130115" />
+    <meta http-equiv="Content-Language" content="en" />
+        
+        </head>
+  <body class="composite">
+    <div id="banner">
+                                      <a href="./" id="bannerLeft">
+                                                <img src="images/JDOx150.gif" alt="Apache
JDO" />
+                </a>
+                                            <a href="./" id="bannerRight">
+                                                <img src="images/jdo_text.gif" alt="Apache
JDO" />
+                </a>
+            <div class="clear">
+        <hr/>
+      </div>
+    </div>
+    <div id="breadcrumbs">
+            
+                    
+                  <div class="xright">                    <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>
+            |
+                        <a href="mail-lists.html" title="Mailing Lists">Mailing Lists</a>
+            |
+                        <a href="api30/apidocs/index.html" title="Latest Javadocs">Latest
Javadocs</a>
+              
+                    
+      </div>
+      <div class="clear">
+        <hr/>
+      </div>
+    </div>
+    <div id="leftColumn">
+      <div id="navcolumn">
+             
+                    
+                                <h5>General</h5>
+                  <ul>
+                  <li class="none">
+                          <a href="index.html" title="Home">Home</a>
+            </li>
+                  <li class="none">
+                          <a href="why_jdo.html" title="Why JDO?">Why JDO?</a>
+            </li>
+                  <li class="none">
+                          <a href="jdo_v_jpa.html" title="JDO v JPA">JDO v JPA</a>
+            </li>
+                  <li class="none">
+                          <a href="jdo_v_jpa_api.html" title="JDO v JPA : API">JDO
v JPA : API</a>
+            </li>
+                  <li class="none">
+                          <a href="jdo_v_jpa_orm.html" title="JDO v JPA : ORM">JDO
v JPA : ORM</a>
+            </li>
+                  <li class="none">
+                          <a href="downloads.html" title="Downloads">Downloads</a>
+            </li>
+                  <li class="none">
+                          <a href="http://www.apache.org/licenses/LICENSE-2.0" class="externalLink"
title="License">License</a>
+            </li>
+          </ul>
+                       <h5>JDO Implementation</h5>
+                  <ul>
+                  <li class="none">
+                          <a href="specifications.html" title="Specifications">Specifications</a>
+            </li>
+                  <li class="none">
+                          <a href="tck.html" title="TCK">TCK</a>
+            </li>
+          </ul>
+                       <h5>JDO Usage</h5>
+                  <ul>
+                  <li class="none">
+                          <a href="impls.html" title="Implementations">Implementations</a>
+            </li>
+                  <li class="none">
+                          <a href="javadoc.html" title="API Javadoc">API Javadoc</a>
+            </li>
+                  <li class="none">
+                          <a href="class_types.html" title="Types of Classes">Types
of Classes</a>
+            </li>
+                  <li class="none">
+                          <a href="field_types.html" title="Types of Fields">Types
of Fields</a>
+            </li>
+                                                                                        
                                 <li class="collapsed">
+                          <a href="metadata.html" title="MetaData">MetaData</a>
+                  </li>
+                  <li class="none">
+                          <a href="enhancement.html" title="Bytecode Enhancement">Bytecode
Enhancement</a>
+            </li>
+                  <li class="none">
+                          <a href="jdohelper.html" title="JDOHelper">JDOHelper</a>
+            </li>
+                  <li class="none">
+                          <a href="pmf.html" title="PersistenceManagerFactory">PersistenceManagerFactory</a>
+            </li>
+                  <li class="none">
+                          <a href="pm.html" title="PersistenceManager">PersistenceManager</a>
+            </li>
+                  <li class="none">
+                          <a href="transactions.html" title="Transactions">Transactions</a>
+            </li>
+                  <li class="none">
+                          <a href="attach_detach.html" title="Attach-Detach">Attach-Detach</a>
+            </li>
+                  <li class="none">
+            <strong>Fetch Groups</strong>
+          </li>
+                  <li class="none">
+                          <a href="state_transition.html" title="Object States">Object
States</a>
+            </li>
+                  <li class="none">
+                          <a href="object_retrieval.html" title="Object Retrieval">Object
Retrieval</a>
+            </li>
+                                                                                        
         <li class="expanded">
+                          <a href="jdoql.html" title="JDOQL">JDOQL</a>
+                    <ul>
+                      <li class="none">
+                          <a href="jdoql_result.html" title="Result">Result</a>
+            </li>
+                      <li class="none">
+                          <a href="jdoql_methods.html" title="Methods">Methods</a>
+            </li>
+                      <li class="none">
+                          <a href="jdoql_quickref.pdf" title="Quick Ref PDF">Quick
Ref PDF</a>
+            </li>
+              </ul>
+        </li>
+                  <li class="none">
+                          <a href="extents.html" title="Extents">Extents</a>
+            </li>
+                                                                                      <li
class="collapsed">
+                          <a href="guides.html" title="Guides">Guides</a>
+                  </li>
+                  <li class="none">
+                          <a href="references.html" title="References">References</a>
+            </li>
+                  <li class="none">
+                          <a href="exceptions.html" title="Exceptions">Exceptions</a>
+            </li>
+                  <li class="none">
+                          <a href="glossary.html" title="Glossary">Glossary</a>
+            </li>
+          </ul>
+                       <h5>Articles</h5>
+                  <ul>
+                  <li class="none">
+                          <a href="jdo_3_0_overview.html" title="JDO 3.0 Overview">JDO
3.0 Overview</a>
+            </li>
+          </ul>
+                       <h5>Community</h5>
+                  <ul>
+                  <li class="none">
+                          <a href="get-involved.html" title="Get Involved">Get Involved</a>
+            </li>
+                  <li class="none">
+                          <a href="team-list.html" title="Project Team">Project Team</a>
+            </li>
+                  <li class="none">
+                          <a href="mail-lists.html" title="Mailing Lists">Mailing Lists</a>
+            </li>
+                  <li class="none">
+                          <a href="faq.html" title="FAQ">FAQ</a>
+            </li>
+          </ul>
+                       <h5>Development</h5>
+                  <ul>
+                  <li class="none">
+                          <a href="roadmap.html" title="RoadMap / TODO">RoadMap / TODO</a>
+            </li>
+                  <li class="none">
+                          <a href="svn.html" title="Source Code">Source Code</a>
+            </li>
+                  <li class="none">
+                          <a href="http://cwiki.apache.org/GMOxDEV/coding-standards.html"
class="externalLink" title="Coding Standards">Coding Standards</a>
+            </li>
+                  <li class="none">
+                          <a href="issuetracking.html" title="Issue Tracking">Issue
Tracking</a>
+            </li>
+                  <li class="none">
+                          <a href="dependencies.html" title="Dependencies">Dependencies</a>
+            </li>
+          </ul>
+                             <a href="http://maven.apache.org/" title="Built by Maven"
class="poweredBy">
+        <img class="poweredBy" alt="Built by Maven" src="./images/logos/maven-feather.png"
/>
+      </a>
+                   
+                    
+            </div>
+    </div>
+    <div id="bodyColumn">
+      <div id="contentBox">
+        
+    
+        <div class="section"><h2>Fetch Groups<a name="Fetch_Groups"></a></h2>
+            <p>
                 When an object is retrieved from the datastore by JDO typically not all fields
are retrieved immediately.
                 This is because for efficiency purposes only particular field types are retrieved
in the initial access 
                 of the object, and then any other objects are retrieved when accessed (lazy
loading). 
-                The group of fields that are loaded is called a <B>fetch group</B>.
-                There are 3 types of "fetch groups" to consider
-            </p><ul>
+                The group of fields that are loaded is called a <b>fetch group</b>.
+                There are 3 types of &quot;fetch groups&quot; to consider
+            </p>
+            <ul>
                 <li><a href="#dfg">Default Fetch Group</a> : defined in
all JDO specs, containing the fields 
                     of a class that will be retrieved by default (with no user specification).</li>
                 <li><a href="#static">Named Fetch Groups</a> : defined
by the JDO2 specification, and defined
@@ -15,140 +221,165 @@
                     The definition here is <i>static</i></li>
                 <li><a href="#dynamic">Dynamic Fetch Groups</a> : Programmatic
definition of fetch groups at 
                     runtime via an API</li>
-            </ul><p>
-                The <B>fetch group</B> in use for a class is controled via the
<I>FetchPlan</I>
-                <a href="http://db.apache.org/jdo/api20/apidocs/javax/jdo/FetchPlan.html"
class="newWindow" title="New Window" target="_blank"><IMG SRC="images/javadoc.gif"></IMG></a>
-                interface. To get a handle on the current <I>FetchPlan</I> we
do
+            </ul>
+            <p>
+                The <b>fetch group</b> in use for a class is controled via the
<i>FetchPlan</i>
+                <a class="externalLink" href="http://db.apache.org/jdo/api20/apidocs/javax/jdo/FetchPlan.html"
target="_blank"><img src="images/javadoc.gif" alt="" /></a>
+                interface. To get a handle on the current <i>FetchPlan</i> we
do
             </p>
-    <div class="source"><pre>FetchPlan fp = pm.getFetchPlan();</pre></div>
-  <br></br><a name="dfg"></a><div class="subsection"><a
name="Default_Fetch_Group"></a><h3>Default Fetch Group</h3><p>
+            <div class="source"><pre>FetchPlan fp = pm.getFetchPlan();</pre></div>
+            <br />
+
+            <a name="dfg"></a>
+            <div class="section"><h3>Default Fetch Group<a name="Default_Fetch_Group"></a></h3>
+                <p>
                     JDO provides an initial fetch group, comprising the fields that will
be retrieved when an object 
-                    is retrieved if the user does nothing to define the required behaviour.
By default the <I>default 
-                    fetch group</I> comprises all fields of the following types :-
-                </p><ul>
+                    is retrieved if the user does nothing to define the required behaviour.
By default the <i>default 
+                    fetch group</i> comprises all fields of the following types :-
+                </p>
+                <ul>
                     <li>primitives : boolean, byte, char, double, float, int, long,
short</li>
                     <li>Object wrappers of primitives : Boolean, Byte, Character, Double,
Float, Integer, Long, Short</li>
                     <li>java.lang.String, java.lang.Number, java.lang.Enum</li>
                     <li>java.math.BigDecimal, java.math.BigInteger</li>
                     <li>java.util.Date</li>
-                </ul><p>
-                    If you wish to change the <B>Default Fetch Group</B> for
a class you can update the Meta-Data 
+                </ul>
+                <p>
+                    If you wish to change the <b>Default Fetch Group</b> for
a class you can update the Meta-Data 
                     for the class as follows (for XML)
                 </p>
-    <div class="source"><pre>
-&lt;class name="MyClass"&gt;
+                <div class="source"><pre>
+&lt;class name=&quot;MyClass&quot;&gt;
     ...
-    &lt;field name="fieldX" default-fetch-group="true"/&gt;
+    &lt;field name=&quot;fieldX&quot; default-fetch-group=&quot;true&quot;/&gt;
 &lt;/class&gt;</pre></div>
-  <p>or using annotations</p>
-    <div class="source"><pre>
-@Persistent(defaultFetchGroup="true")
+                <p>or using annotations</p>
+                <div class="source"><pre>
+@Persistent(defaultFetchGroup=&quot;true&quot;)
 SomeType fieldX;</pre></div>
-  <p>
-                    When a <I>PersistenceManager</I> is created it starts with
a FetchPlan of the "default" fetch group. 
+                <p>
+                    When a <i>PersistenceManager</i> is created it starts with
a FetchPlan of the &quot;default&quot; fetch group. 
                     That is, if we call
                 </p>
-    <div class="source"><pre>Collection fetchGroups = fp.getGroups();</pre></div>
-  <p>
-                    this will have one group, called "default". At runtime, if you have been
using other 
+                <div class="source"><pre>Collection fetchGroups = fp.getGroups();</pre></div>
+                <p>
+                    this will have one group, called &quot;default&quot;. At runtime,
if you have been using other 
                     fetch groups and want to revert back to the default fetch group at any
time you simply do
                 </p>
-    <div class="source"><pre>fp.setGroup(FetchPlan.DEFAULT);</pre></div>
-  <br></br></div><a name="static"></a><div class="subsection"><a
name="Named_Fetch_Groups"></a><h3>Named Fetch Groups</h3><p>
+                <div class="source"><pre>fp.setGroup(FetchPlan.DEFAULT);</pre></div>
+                <br />
+            </div>
+
+            <a name="static"></a>
+            <div class="section"><h3>Named Fetch Groups<a name="Named_Fetch_Groups"></a></h3>
+                <p>
                     As mentioned above, JDO allows specification of users own fetch groups.
These are specified in the 
                     MetaData of the class. For example, if we have the following class
                 </p>
-    <div class="source"><pre>
+                <div class="source"><pre>
 class MyClass
 {
     String name;
     HashSet coll;
     MyOtherClass other;
 }</pre></div>
-  <p>
-                    and we want to have the <U>other</U> field loaded whenever
we load objects of this class, we define 
+                <p>
+                    and we want to have the <u>other</u> field loaded whenever
we load objects of this class, we define 
                     our MetaData as
                 </p>
-    <div class="source"><pre>
-&lt;package name="mydomain"&gt;
-    &lt;class name="MyClass"&gt;
-        &lt;field name="name"&gt;
-            &lt;column length="100" jdbc-type="VARCHAR"/&gt;
+                <div class="source"><pre>
+&lt;package name=&quot;mydomain&quot;&gt;
+    &lt;class name=&quot;MyClass&quot;&gt;
+        &lt;field name=&quot;name&quot;&gt;
+            &lt;column length=&quot;100&quot; jdbc-type=&quot;VARCHAR&quot;/&gt;
         &lt;/field&gt;
-        &lt;field name="coll" persistence-modifier="persistent"&gt;
-            &lt;collection element-type="mydomain.Address"/&gt;
+        &lt;field name=&quot;coll&quot; persistence-modifier=&quot;persistent&quot;&gt;
+            &lt;collection element-type=&quot;mydomain.Address&quot;/&gt;
             &lt;join/&gt;
         &lt;/field&gt;
-        &lt;field name="other" persistence-modifier="persistent"/&gt;
-        &lt;fetch-group name="otherfield"&gt;
-            &lt;field name="other"/&gt;
+        &lt;field name=&quot;other&quot; persistence-modifier=&quot;persistent&quot;/&gt;
+        &lt;fetch-group name=&quot;otherfield&quot;&gt;
+            &lt;field name=&quot;other&quot;/&gt;
         &lt;/fetch-group&gt;
     &lt;/class&gt;
 &lt;/package&gt;</pre></div>
-  <p>or using annotations</p>
-    <div class="source"><pre>
+                <p>or using annotations</p>
+                <div class="source"><pre>
 @PersistenceCapable
-@FetchGroup(name="otherfield", members={@Persistent(name="other")})
+@FetchGroup(name=&quot;otherfield&quot;, members={@Persistent(name=&quot;other&quot;)})
 public class MyClass
 {
     ...
 }</pre></div>
-  <p>
-                    So we have defined a fetch group called "otherfield" that just includes
the field with name 
-                    <I>other</I>. We can then use this at runtime in our persistence
code.
+                <p>
+                    So we have defined a fetch group called &quot;otherfield&quot;
that just includes the field with name 
+                    <i>other</i>. We can then use this at runtime in our persistence
code.
                 </p>
-    <div class="source"><pre>
+                <div class="source"><pre>
 PersistenceManager pm = pmf.getPersistenceManager();
-pm.getFetchPlan().addGroup("otherfield");
+pm.getFetchPlan().addGroup(&quot;otherfield&quot;);
 
 ... (load MyClass object)</pre></div>
-  <p>
-                    By default the <I>FetchPlan</I> will include the default
fetch group. We have changed this above by
-                    <U>adding</U> the fetch group "otherfield", so when we retrieve
an object using this 
-                    <I>PersistenceManager</I> we will be retrieving the fields
<I>name</I> AND <I>other</I> since they
-                    are both in the current <I>FetchPlan</I>. We can take the
above much further than what is shown by 
-                    defining nested fetch groups in the MetaData. In addition we can change
the <I>FetchPlan</I> just
-                    before any <I>PersistenceManager</I> operation to control
what is fetched during that operation.
-                    The user has full flexibility to add many groups to the current <B>Fetch
Plan</B>.
+                <p>
+                    By default the <i>FetchPlan</i> will include the default
fetch group. We have changed this above by
+                    <u>adding</u> the fetch group &quot;otherfield&quot;,
so when we retrieve an object using this 
+                    <i>PersistenceManager</i> we will be retrieving the fields
<i>name</i> AND <i>other</i> since they
+                    are both in the current <i>FetchPlan</i>. We can take the
above much further than what is shown by 
+                    defining nested fetch groups in the MetaData. In addition we can change
the <i>FetchPlan</i> just
+                    before any <i>PersistenceManager</i> operation to control
what is fetched during that operation.
+                    The user has full flexibility to add many groups to the current <b>Fetch
Plan</b>.
                     This gives much power and control over what will be loaded and when.
-                </p><p>
-                    The <I>FetchPlan</I> applies not just to calls to <I>PersistenceManager.getObjectById()</I>,
but also
-                    to <I>PersistenceManager.newQuery()</I>, <I>PersistenceManager.getExtent()</I>,

-                    <I>PersistenceManager.detachCopy</I> and much more besides.
-                </p><p>
-                    You can read more about <B>named fetch-groups</B> and how
to use it with 
-                    <a href="attach_detach.html"><B>attach/detach</B></a>
-                </p></div><a name="dynamic"></a><div class="subsection"><a
name="Dynamic_Fetch_Groups"></a><h3>Dynamic Fetch Groups</h3><p>
+                </p>
+                <p>
+                    The <i>FetchPlan</i> applies not just to calls to <i>PersistenceManager.getObjectById()</i>,
but also
+                    to <i>PersistenceManager.newQuery()</i>, <i>PersistenceManager.getExtent()</i>,

+                    <i>PersistenceManager.detachCopy</i> and much more besides.
+                </p>
+                <p>
+                    You can read more about <b>named fetch-groups</b> and how
to use it with 
+                    <a href="attach_detach.html"><b>attach/detach</b></a>
+                </p>
+            </div>
+
+            <a name="dynamic"></a>
+            <div class="section"><h3>Dynamic Fetch Groups<a name="Dynamic_Fetch_Groups"></a></h3>
+                <p>
                     The mechanism above provides static fetch groups defined in XML or annotations.

                     That is great when you know in advance what fields you want to fetch.
In some situations 
                     you may want to define your fields to fetch at run time. This became
standard in JDO2.2
                     It operates as follows
                 </p>
-    <div class="source"><pre>
+                <div class="source"><pre>
 import org.datanucleus.FetchGroup;
 
-// Create a FetchGroup on the PMF called "TestGroup" for MyClass
-FetchGroup grp = myPMF.getFetchGroup("TestGroup", MyClass.class);
-grp.addMember("field1").addMember("field2");
+// Create a FetchGroup on the PMF called &quot;TestGroup&quot; for MyClass
+FetchGroup grp = myPMF.getFetchGroup(&quot;TestGroup&quot;, MyClass.class);
+grp.addMember(&quot;field1&quot;).addMember(&quot;field2&quot;);
 
 // Add this group to the fetch plan (using its name)
-fp.addGroup("TestGroup");</pre></div>
-  <p>
+fp.addGroup(&quot;TestGroup&quot;);</pre></div>
+                <p>
                     So we use the DataNucleus PMF as a way of creating a FetchGroup, and
then register that 
                     FetchGroup with the PMF for use by all PMs. We then enable our FetchGroup
for use in the
                     FetchPlan by using its group name (as we do for a static group). The
FetchGroup allows you 
                     to add/remove the fields necessary so you have full API control over
the fields to be 
                     fetched.
-                </p><br></br></div><div class="subsection"><a
name="Fetch_Depth"></a><h3>Fetch Depth</h3><p>
+                </p>
+                <br />
+            </div>
+
+            <div class="section"><h3>Fetch Depth<a name="Fetch_Depth"></a></h3>
+                <p>
                     The basic fetch group defines which fields are to be fetched. It doesn't
explicitly define how far 
                     down an object graph is to be fetched. JDO provides two ways of controlling
this.
-                </p><p>
-                    The first is to set the <B>maxFetchDepth</B> for the <I>FetchPlan</I>.
This value specifies how 
+                </p>
+                <p>
+                    The first is to set the <b>maxFetchDepth</b> for the <i>FetchPlan</i>.
This value specifies how 
                     far out from the root object the related objects will be fetched. A positive
value means that 
                     this number of relationships will be  traversed from the root object.
A value of -1 means that 
                     no limit will be placed on the fetching traversal. The default is 1.
Let's take an example
                 </p>
-    <div class="source"><pre>
+                <div class="source"><pre>
 public class MyClass1
 {
     MyClass2 field1;
@@ -166,64 +397,86 @@ public class MyClass3
     MyClass4 field3;
     ...
 }</pre></div>
-  <p>
-                    and we want to detach <I>field1</I> of instances of <I>MyClass1</I>,
down 2 levels - so detaching 
-                    the initial "field1" <I>MyClass2</I> object, and its "field2"
<I>MyClass3</I> instance. So we 
+                <p>
+                    and we want to detach <i>field1</i> of instances of <i>MyClass1</i>,
down 2 levels - so detaching 
+                    the initial &quot;field1&quot; <i>MyClass2</i> object,
and its &quot;field2&quot; <i>MyClass3</i> instance. So we 
                     define our fetch-groups like this
                 </p>
-    <div class="source"><pre>
-&lt;class name="MyClass1"&gt;
+                <div class="source"><pre>
+&lt;class name=&quot;MyClass1&quot;&gt;
     ...
-    &lt;fetch-group name="includingField1"&gt;
-        &lt;field name="field1"/&gt;
+    &lt;fetch-group name=&quot;includingField1&quot;&gt;
+        &lt;field name=&quot;field1&quot;/&gt;
     &lt;/fetch-group&gt;
 &lt;/class&gt;
-&lt;class name="MyClass2"&gt;
+&lt;class name=&quot;MyClass2&quot;&gt;
     ...
-    &lt;fetch-group name="includingField2"&gt;
-        &lt;field name="field2"/&gt;
+    &lt;fetch-group name=&quot;includingField2&quot;&gt;
+        &lt;field name=&quot;field2&quot;/&gt;
     &lt;/fetch-group&gt;
 &lt;/class&gt;</pre></div>
-  <p>
-                    and we then define the <B>maxFetchDepth</B> as 2, like this
+                <p>
+                    and we then define the <b>maxFetchDepth</b> as 2, like this
                 </p>
-    <div class="source"><pre>pm.getFetchPlan().setMaxFetchDepth(2);</pre></div>
-  <p>
+                <div class="source"><pre>pm.getFetchPlan().setMaxFetchDepth(2);</pre></div>
+                <p>
                     A further refinement to this global fetch depth setting is to control
the fetching of recursive 
-                    fields. This is performed via a MetaData setting "recursion-depth". A
value of 1 means that only 
+                    fields. This is performed via a MetaData setting &quot;recursion-depth&quot;.
A value of 1 means that only 
                     1 level of objects will be fetched. A value of -1 means there is no limit
on the amount of recursion. 
                     The default is 1. Let's take an example
                 </p>
-    <div class="source"><pre>
+                <div class="source"><pre>
 public class Directory
 {
     Collection children;
     ...
 }</pre></div>
-  
-    <div class="source"><pre>
-&lt;class name="Directory"&gt;
-    &lt;field name="children"&gt;
-        &lt;collection element-type="Directory"/&gt;
+                <div class="source"><pre>
+&lt;class name=&quot;Directory&quot;&gt;
+    &lt;field name=&quot;children&quot;&gt;
+        &lt;collection element-type=&quot;Directory&quot;/&gt;
     &lt;/field&gt;
 
-    &lt;fetch-group name="grandchildren"&gt;
-        &lt;field name="children" recursion-depth="2"/&gt;
+    &lt;fetch-group name=&quot;grandchildren&quot;&gt;
+        &lt;field name=&quot;children&quot; recursion-depth=&quot;2&quot;/&gt;
     &lt;/fetch-group&gt;
     ...
 &lt;/class&gt;</pre></div>
-  <p>
-                    So when we fetch a Directory, it will fetch 2 levels of the <I>children</I>
field, hence fetching 
+                <p>
+                    So when we fetch a Directory, it will fetch 2 levels of the <i>children</i>
field, hence fetching 
                     the children and the grandchildren.
-                </p></div><div class="subsection"><a name="Fetch_Size"></a><h3>Fetch
Size</h3><p>
+                </p>
+            </div>
+
+            <div class="section"><h3>Fetch Size<a name="Fetch_Size"></a></h3>
+                <p>
                     A FetchPlan can also be used for defining the fetching policy when using
queries. This can be 
                     set using
                 </p>
-    <div class="source"><pre>pm.getFetchPlan().setFetchSize(value);</pre></div>
-  <p>
-                    The default is <I>FetchPlan.FETCH_SIZE_OPTIMAL</I> which
leaves it to DataNucleus to optimise the fetching
+                <div class="source"><pre>pm.getFetchPlan().setFetchSize(value);</pre></div>
+                <p>
+                    The default is <i>FetchPlan.FETCH_SIZE_OPTIMAL</i> which
leaves it to DataNucleus to optimise the fetching
                     of instances. A positive value defines the number of instances to be
fetched. Using 
-                    <I>FetchPlan.FETCH_SIZE_GREEDY</I> means that all instances
will be fetched immediately.
-                </p></div></div></div></div><div class="clear"><hr></hr></div><table
border="0" width="100%" cellpadding="0" cellspacing="0"><tr><td width="100%"><img
height="1" border="0" width="100%" src="./images/header_line.gif"></img></td></tr></table><div
id="footer"><div class="xright"><a href="http://www.apache.org/foundation/sponsorship.html">Be
an Apache Software Foundation sponsor</a><br><a href="http://www.apache.org/foundation/thanks.html">Thanks
to ASF sponsors!</a></br></div><div class="xleft">
-                Documentation published: <br></br>
-                  © 2005-2011 <a href="http://www.apache.org/">Apache Software Foundation</a></div></div></body></html>
\ No newline at end of file
+                    <i>FetchPlan.FETCH_SIZE_GREEDY</i> means that all instances
will be fetched immediately.
+                </p>
+            </div>
+        </div>
+    
+
+      </div>
+    </div>
+    <div class="clear">
+      <hr/>
+    </div>
+    <div id="footer">
+      <div class="xright">
+              Copyright &#169;                   2005-2013.
+          All Rights Reserved.      
+                    
+                  </div>
+      <div class="clear">
+        <hr/>
+      </div>
+    </div>
+  </body>
+</html>



Mime
View raw message