cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1361654 - /cayenne/main/branches/STABLE-3.1/docs/docbook/cayenne-guide/src/docbkx/persistent-objects-objectcontext.xml
Date Sun, 15 Jul 2012 08:22:24 GMT
Author: aadamchik
Date: Sun Jul 15 08:22:23 2012
New Revision: 1361654

URL: http://svn.apache.org/viewvc?rev=1361654&view=rev
Log:
docs
(cherry picked from commit 33ca28e7031a6e8ed0359f629b0c4d28da8cbdd8)

Modified:
    cayenne/main/branches/STABLE-3.1/docs/docbook/cayenne-guide/src/docbkx/persistent-objects-objectcontext.xml

Modified: cayenne/main/branches/STABLE-3.1/docs/docbook/cayenne-guide/src/docbkx/persistent-objects-objectcontext.xml
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.1/docs/docbook/cayenne-guide/src/docbkx/persistent-objects-objectcontext.xml?rev=1361654&r1=1361653&r2=1361654&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-3.1/docs/docbook/cayenne-guide/src/docbkx/persistent-objects-objectcontext.xml
(original)
+++ cayenne/main/branches/STABLE-3.1/docs/docbook/cayenne-guide/src/docbkx/persistent-objects-objectcontext.xml
Sun Jul 15 08:22:23 2012
@@ -122,9 +122,23 @@ artist.setName("Picasso");</programlisti
 			internally generates a minimal set of SQL statements to synchronize the database with
 			the in-memory state of all changed objects and sends them to DB in a single
 			transaction.</para>
+		<para>Finally ObjectContext provides access to all the mapping metadata that can
often be
+			useful to the application. Metadata is accessed via EntityResolver
+			object:<programlisting>EntityResolver resolver = objectContext.getEntityResolver();</programlisting></para>
 	</section>
 	<section xml:id="cayenne-helper-class">
 		<title>Cayenne Helper Class</title>
+		<para>There is a useful helper class called "Cayenne" (fully-qualified name
+				<code>"org.apache.cayenne.Cayenne"</code>) that builds on ObjectContext API
to
+			provide a number of very common operations. E.g. get a primary key (most entities do not
+			model PK as an object property)
+			:<programlisting>long pk = Cayenne.longPKForObject(artist);</programlisting></para>
+		<para>It also provides the reverse operation - finding an object given a known
+			PK:<programlisting>Artist artist = Cayenne.objectForPK(context, Artist.class, 34579);</programlisting></para>
+		<para>If a query is expected to return 0 or 1 object, Cayenne helper class can be
used
+			tofind this object. It throws an exception if more than one object matched the
+			query:<programlisting>Artist artist = (Artist) Cayenne.objectForQuery(context, new
SelectQuery(Artist.class));</programlisting></para>
+		<para>Feel free to explore Cayenne class API for other useful methods.</para>
 	</section>
 	<section xml:id="objectcontext-nesting">
 		<title>ObjectContext Nesting</title>



Mime
View raw message