This is an automated email from the ASF dual-hosted git repository.

stariy95 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cayenne.git


The following commit(s) were added to refs/heads/master by this push:
     new 19f33d9ec Fix code examples
19f33d9ec is described below

commit 19f33d9ecf38ee98e2dcf855756944b28161609e
Author: ntimofeev <[email protected]>
AuthorDate: Thu Aug 20 17:48:35 2026 +0300

    Fix code examples
---
 README.md | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/README.md b/README.md
index 5b57b325b..95edf7745 100644
--- a/README.md
+++ b/README.md
@@ -66,7 +66,7 @@ implementation 'org.apache.cayenne:cayenne:5.0-M2'
 ```java
 CayenneRuntime cayenneRuntime = CayenneRuntime.of()
     .addConfig("cayenne-demo.xml")
-    .dataSource(CayenneDataSource
+    .defaultDataNode(CayenneDataSource
              .of("jdbc:mysql://localhost:3306/cayenne_demo")
              .userName("username")
              .password("password")
@@ -112,13 +112,19 @@ List<Painting> paintings = 
ObjectSelect.query(Painting.class)
         .select(context);
 ```
 
-#### Aggregate Functions
+#### Exists Subqueries
 
 ```java
-// this is artificial property signaling that we want to get full object
-Property<Artist> artistProperty = Property.createSelf(Artist.class);
+long count = ObjectSelect.query(Artist.class)
+    
.where(Artist.PAINTING_ARRAY.dot(Painting.PAINTING_TITLE).like("painting%").exists())
+    .selectCount(context);
+```
 
-List<Object[]> artistAndPaintingCount = ObjectSelect.columnQuery(Artist.class, 
artistProperty, Artist.PAINTING_ARRAY.count())
+#### Aggregate Functions
+
+```java
+List<Object[]> artistAndPaintingCount = ObjectSelect
+    .columnQuery(Artist.class, Artist.SELF, Artist.PAINTING_ARRAY.count())
     .where(Artist.ARTIST_NAME.like("a%"))
     .having(Artist.PAINTING_ARRAY.count().lt(5L))
     .orderBy(Artist.PAINTING_ARRAY.count().desc(), Artist.ARTIST_NAME.asc())
@@ -138,7 +144,7 @@ for(Object[] next : artistAndPaintingCount) {
 // Selecting objects
 List<Painting> paintings = SQLSelect
     .query(Painting.class, "SELECT * FROM PAINTING WHERE PAINTING_TITLE LIKE 
#bind($title)")
-    .params("title", "painting%")
+    .param("title", "painting%")
     .upperColumnNames()
     .localCache()
     .limit(100)
@@ -146,8 +152,8 @@ List<Painting> paintings = SQLSelect
 
 // Selecting scalar values
 List<String> paintingNames = SQLSelect
-    .scalarQuery(String.class, "SELECT PAINTING_TITLE FROM PAINTING WHERE 
ESTIMATED_PRICE > #bind($price)")
-    .params("price", 100000)
+    .scalarQuery("SELECT PAINTING_TITLE FROM PAINTING WHERE ESTIMATED_PRICE > 
#bind($price)", String.class)
+    .param("price", 100000)
     .select(context);
 
 // Insert values

Reply via email to