openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r627889 - /openjpa/trunk/openjpa-project/src/doc/manual/ref_guide_slice.xml
Date Thu, 14 Feb 2008 22:17:14 GMT
Author: ppoddar
Date: Thu Feb 14 14:17:12 2008
New Revision: 627889

URL: http://svn.apache.org/viewvc?rev=627889&view=rev
Log:
OPENJPA-515 Add documentation for targeted query via query hints

Modified:
    openjpa/trunk/openjpa-project/src/doc/manual/ref_guide_slice.xml

Modified: openjpa/trunk/openjpa-project/src/doc/manual/ref_guide_slice.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-project/src/doc/manual/ref_guide_slice.xml?rev=627889&r1=627888&r2=627889&view=diff
==============================================================================
--- openjpa/trunk/openjpa-project/src/doc/manual/ref_guide_slice.xml (original)
+++ openjpa/trunk/openjpa-project/src/doc/manual/ref_guide_slice.xml Thu Feb 14 14:17:12 2008
@@ -87,6 +87,19 @@
              update to any of these instances is committed to the appropriate 
              original database slice. 
             </para>
+            
+            <note>
+            <para>
+            You can find the original slice of an instance <code>pc</code> by

+            the static utility method  
+            <methodname>SlicePersistence.getSlice(pc)</methodname>.
+            This method returns the slice identifier string associated with the
+            given <emphasis>managed</emphasis> instance. If the instance is not
+            being managed then the method return null because any unmanaged or
+            detached instance is not associated with any slice. 
+            </para>
+            </note>
+            
             <para>
             <warning>Currently, there is no provision for migrating an 
             existing instance from one slice to another.
@@ -129,7 +142,34 @@
             The aggregate operation <code>AVG()</code> is not supported.
             </warning>
             </para>
+            
          </section>
+         
+         <section><title>Targeted Query</title>
+            <para>
+            You can target the query only to a subset of slices rather than
+            all slices by setting a <emphasis>hint</emphasis>. The hint key
+            <code>openjpa.hint.slice.Target</code> is set on any query and 
+            hint value is
+            comma-separated list of slice identifiers. The following 
+            example shows how to target a query only to slice <code>"One"</code>
+                          
+            <programlisting>
+              <![CDATA[EntityManager em = ...;
+              em.getTransaction().begin();
+              String hint = "openjpa.hint.slice.Target";
+              Query query = em.createQuery("SELECT p FROM PObject").setHint(hint, "One");
+              List result = query.getResultList();
+              // verify that each instance is originaing from the given slice
+              for (Object pc : result) {
+                 String sliceOrigin = SlicePersistence.getSlice(pc);
+                 assertTrue ("One", sliceOrigin);
+              }
+              ]]>
+            </programlisting> 
+            </para>
+         </section>
+         
          
          <section><title>Distributed Transaction</title>
             <para> 



Mime
View raw message