Repository: cayenne
Updated Branches:
  refs/heads/master 29f00435e -> f72db8b20


Update tutorial's 'Selecting Objects' section to use ObjectSelect instead of 
outdated SelectQuery examples


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/f72db8b2
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/f72db8b2
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/f72db8b2

Branch: refs/heads/master
Commit: f72db8b20f636ddb5a9f438c85eb3d16b0f59c38
Parents: 29f0043
Author: Dzmitry Kazimirchyk <[email protected]>
Authored: Mon Feb 29 18:20:09 2016 +0300
Committer: Dzmitry Kazimirchyk <[email protected]>
Committed: Mon Feb 29 18:20:09 2016 +0300

----------------------------------------------------------------------
 .../getting-started/src/docbkx/select-query.xml | 30 ++++++++------------
 1 file changed, 12 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/f72db8b2/docs/docbook/getting-started/src/docbkx/select-query.xml
----------------------------------------------------------------------
diff --git a/docs/docbook/getting-started/src/docbkx/select-query.xml 
b/docs/docbook/getting-started/src/docbkx/select-query.xml
index efe9ebd..bcc5dce 100644
--- a/docs/docbook/getting-started/src/docbkx/select-query.xml
+++ b/docs/docbook/getting-started/src/docbkx/select-query.xml
@@ -18,21 +18,20 @@
 <chapter xmlns="http://docbook.org/ns/docbook";
     xmlns:xlink="http://www.w3.org/1999/xlink"; version="5.0">
     <title>Selecting Objects</title>
-    <para>This chapter shows how to select objects from the database using 
SelectQuery. </para>
+    <para>This chapter shows how to select objects from the database using 
ObjectSelect query. </para>
     <section xml:id="introducing-select-query">
-        <title>Introducing SelectQuery</title>
+        <title>Introducing ObjectSelect</title>
         <para>It was shown before how to persist new objects. Cayenne queries 
are used to access
             already saved objects. The primary query type used for selecting 
objects is <emphasis
-                role="italic">SelectQuery</emphasis>. It can be mapped in 
CayenneModeler or created
-            via the API. We'll use the later approach in this section. We 
don't have too much data
+                role="italic">ObjectSelect</emphasis>. It can be mapped in 
CayenneModeler or created
+            via the API. We'll use the latter approach in this section. We 
don't have too much data
             in the database yet, but we can still demonstrate the main 
principles below.</para>
         <itemizedlist>
             <listitem>
                 <para>Select all paintings (the code, and the log output it 
generates):</para>
             </listitem>
         </itemizedlist>
-        <programlisting language="java">SelectQuery select1 = new 
SelectQuery(Painting.class);
-List paintings1 = context.performQuery(select1);</programlisting>
+        <programlisting language="java">List&lt;Painting> paintings1 =  
ObjectSelect.query(Painting.class).select(context); </programlisting>
         <programlisting>INFO: SELECT t0.GALLERY_ID, t0.ARTIST_ID, t0.NAME, 
t0.ID FROM PAINTING t0
 INFO: === returned 2 rows. - took 18 ms.</programlisting>
         <itemizedlist>
@@ -40,28 +39,23 @@ INFO: === returned 2 rows. - took 18 ms.</programlisting>
                 <para>Select paintings that start with "gi", ignoring 
case:</para>
             </listitem>
         </itemizedlist>
-        <programlisting language="java">Expression qualifier2 = 
ExpressionFactory.likeIgnoreCaseExp(
-                Painting.NAME_PROPERTY,
-                "gi%");
-SelectQuery select2 = new SelectQuery(Painting.class, qualifier2);
-List paintings2 = context.performQuery(select2);</programlisting>
+        <programlisting language="java">List&lt;Painting> paintings2 = 
ObjectSelect.query(Painting.class)
+        .where(Painting.NAME.likeIgnoreCase("gi%")).select(context); 
</programlisting>
         <programlisting>INFO: SELECT t0.GALLERY_ID, t0.NAME, t0.ARTIST_ID, 
t0.ID FROM PAINTING t0 WHERE UPPER(t0.NAME) LIKE UPPER(?)
       [bind: 1->NAME:'gi%'] - prepared in 6 ms.
 INFO: === returned 1 row. - took 18 ms.</programlisting>
         <itemizedlist>
             <listitem>
-                <para>Select all paintings done by artists who were born more 
than a 100 years ago
-                    (demonstrating using Expression.fromString(..) instead of
-                    ExpressionFactory):</para>
+                <para>Select all paintings done by artists who were born more 
than a 100 years
+                    ago:</para>
             </listitem>
         </itemizedlist>
         <programlisting language="java">Calendar c = new GregorianCalendar();
 c.set(c.get(Calendar.YEAR) - 100, 0, 1, 0, 0, 0);
 
-Expression qualifier3 = Expression.fromString("artist.dateOfBirth &lt; $date");
-qualifier3 = qualifier3.expWithParameters(Collections.singletonMap("date", 
c.getTime()));
-SelectQuery select3 = new SelectQuery(Painting.class, qualifier3);
-List paintings3 = context.performQuery(select3);</programlisting>
+List&lt;Painting> paintings3 = ObjectSelect.query(Painting.class)
+        .where(Painting.ARTIST.dot(Artist.DATE_OF_BIRTH).lt(c.getTime()))
+        .select(context); </programlisting>
         <programlisting>INFO: SELECT t0.GALLERY_ID, t0.NAME, t0.ARTIST_ID, 
t0.ID FROM PAINTING t0 JOIN ARTIST t1 ON (t0.ARTIST_ID = t1.ID)
       WHERE t1.DATE_OF_BIRTH &lt; ? [bind: 1->DATE_OF_BIRTH:'1911-01-01 
00:00:00.493'] - prepared in 7 ms.
 INFO: === returned 2 rows. - took 25 ms.</programlisting>

Reply via email to