cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dkazimirc...@apache.org
Subject svn commit: r1733161 - /cayenne/site/cms/trunk/content/docs/4.0/tutorial/ch08.html
Date Tue, 01 Mar 2016 21:55:09 GMT
Author: dkazimirchyk
Date: Tue Mar  1 21:55:09 2016
New Revision: 1733161

URL: http://svn.apache.org/viewvc?rev=1733161&view=rev
Log:
Update Cayenne 'Deleting Objects' tutorial to use ObjectSelect instead of old SelectQuery
in code example

Modified:
    cayenne/site/cms/trunk/content/docs/4.0/tutorial/ch08.html

Modified: cayenne/site/cms/trunk/content/docs/4.0/tutorial/ch08.html
URL: http://svn.apache.org/viewvc/cayenne/site/cms/trunk/content/docs/4.0/tutorial/ch08.html?rev=1733161&r1=1733160&r2=1733161&view=diff
==============================================================================
--- cayenne/site/cms/trunk/content/docs/4.0/tutorial/ch08.html (original)
+++ cayenne/site/cms/trunk/content/docs/4.0/tutorial/ch08.html Tue Mar  1 21:55:09 2016
@@ -19,9 +19,7 @@
                     exist without being displayed in a gallery.</p></li><li
class="listitem"><p>For Painting et both relationships rules to "Nullify".</p></li></ul></div><p>Now
save the mapping, and refresh the project in Eclispe.</p></div><div class="section"
title="Deleting Objects"><div class="titlepage"><div><div><h2 class="title"><a
name="deleting-objects"></a>Deleting Objects</h2></div></div></div><p>While
deleting objects is possible via SQL, qualifying a delete on one or more IDs, a
             more common way in Cayenne (or ORM in general) is to get a hold of the object
first, and
             then delete it via the context. Let's use utility class Cayenne to find an
-            artist:</p><pre class="programlisting">Expression qualifier = ExpressionFactory.matchExp(Artist.NAME_PROPERTY,
<span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">"Pablo Picasso"</span>);
-SelectQuery select = <span xmlns="http://www.w3.org/1999/xhtml" class="hl-keyword">new</span>
SelectQuery(Artist.<span xmlns="http://www.w3.org/1999/xhtml" class="hl-keyword">class</span>,
qualifier);
-Artist picasso = (Artist) Cayenne.objectForQuery(context, select);</pre><p>Now
let's delete the artist:</p><pre class="programlisting"><span xmlns="http://www.w3.org/1999/xhtml"
class="hl-keyword">if</span> (picasso != null) {
+            artist:</p><pre class="programlisting">Artist picasso = ObjectSelect.query(Artist.<span
xmlns="http://www.w3.org/1999/xhtml" class="hl-keyword">class</span>).where(Artist.NAME.eq(<span
xmlns="http://www.w3.org/1999/xhtml" class="hl-string">"Pablo Picasso"</span>)).selectOne(context);</pre><p>Now
let's delete the artist:</p><pre class="programlisting"><span xmlns="http://www.w3.org/1999/xhtml"
class="hl-keyword">if</span> (picasso != null) {
     context.deleteObject(picasso);
     context.commitChanges();
 }</pre><p>Since we set up "Cascade" delete rule for the Artist.paintings relationships,
Cayenne



Mime
View raw message