cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dkazimirc...@apache.org
Subject [2/3] cayenne git commit: CAY-2065 Update ROP client tutorial code to use modern ObjectSelect instead of unparameterized SelectQuery
Date Tue, 01 Mar 2016 16:56:50 GMT
CAY-2065 Update ROP client tutorial code to use modern ObjectSelect instead of unparameterized
SelectQuery


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

Branch: refs/heads/master
Commit: 812b1d837c152654a9d1715e95b624abcc758b45
Parents: 10c0790
Author: Dzmitry Kazimirchyk <dkazimirchyk@gmail.com>
Authored: Tue Mar 1 19:22:35 2016 +0300
Committer: Dzmitry Kazimirchyk <dkazimirchyk@gmail.com>
Committed: Tue Mar 1 19:22:35 2016 +0300

----------------------------------------------------------------------
 .../cayenne/tutorial/persistent/client/Main.java   | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/812b1d83/tutorials/tutorial-rop-client/src/main/java/org/apache/cayenne/tutorial/persistent/client/Main.java
----------------------------------------------------------------------
diff --git a/tutorials/tutorial-rop-client/src/main/java/org/apache/cayenne/tutorial/persistent/client/Main.java
b/tutorials/tutorial-rop-client/src/main/java/org/apache/cayenne/tutorial/persistent/client/Main.java
index 3997b06..edfd4a8 100644
--- a/tutorials/tutorial-rop-client/src/main/java/org/apache/cayenne/tutorial/persistent/client/Main.java
+++ b/tutorials/tutorial-rop-client/src/main/java/org/apache/cayenne/tutorial/persistent/client/Main.java
@@ -27,6 +27,7 @@ import org.apache.cayenne.ObjectContext;
 import org.apache.cayenne.configuration.Constants;
 import org.apache.cayenne.configuration.rop.client.ClientRuntime;
 import org.apache.cayenne.exp.Expression;
+import org.apache.cayenne.query.ObjectSelect;
 import org.apache.cayenne.query.SelectQuery;
 
 public class Main {
@@ -75,20 +76,16 @@ public class Main {
     }
 
     static void selectTutorial(ObjectContext context) {
-        // SelectQuery examples
-        SelectQuery<Painting> select1 = SelectQuery.query(Painting.class);
-        List<Painting> paintings1 = context.select(select1);
+        // ObjectSelect examples
+        List<Painting> paintings1 = ObjectSelect.query(Painting.class).select(context);
 
-        Expression qualifier2 = Painting.NAME.likeIgnoreCase("gi%");
-        SelectQuery<Painting> select2 = SelectQuery.query(Painting.class, qualifier2);
-        List<Painting> paintings2 = context.select(select2);
+        List<Painting> paintings2 = ObjectSelect.query(Painting.class)
+                .where(Painting.NAME.likeIgnoreCase("gi%")).select(context);
     }
 
     static void deleteTutorial(ObjectContext context) {
-        // Delete object examples
-        Expression qualifier = Artist.NAME.eq("Pablo Picasso");
-        SelectQuery<Artist> selectToDelete = SelectQuery.query(Artist.class, qualifier);
-        Artist picasso = (Artist) Cayenne.objectForQuery(context, selectToDelete);
+        // Delete object example
+        Artist picasso = ObjectSelect.query(Artist.class).where(Artist.NAME.eq("Pablo Picasso")).selectOne(context);
 
         if (picasso != null) {
             context.deleteObjects(picasso);


Mime
View raw message