This is an automated email from the ASF dual-hosted git repository. ntimofeev pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/cayenne-website.git
The following commit(s) were added to refs/heads/master by this push: new fd8841371 Update 5.0 docs fd8841371 is described below commit fd884137155b7436ef79fc27795cbb327bf899a2 Author: Nikita Timofeev <stari...@gmail.com> AuthorDate: Fri Aug 2 14:42:36 2024 +0400 Update 5.0 docs --- .../content/docs/5.0/cayenne-guide/queries.html | 32 +++++++++++++++------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/src/main/site/content/docs/5.0/cayenne-guide/queries.html b/src/main/site/content/docs/5.0/cayenne-guide/queries.html index 6dbd1158d..6cfc54b00 100644 --- a/src/main/site/content/docs/5.0/cayenne-guide/queries.html +++ b/src/main/site/content/docs/5.0/cayenne-guide/queries.html @@ -69,7 +69,7 @@ INFO: === returned 5 row. - took 5 ms.</code></pre> </div> </div> <div class="paragraph"> - <p>This SQL was generated by Cayenne from the <code>ObjectSelect</code> above. <code>ObjectSelect</code> can have a qualifier to select only the data matching specific criteria. Qualifier is simply an Expression (Expressions where discussed in the previous chapter), appended to the query using "where" method. If you only want artists whose name begins with 'Pablo', you might use the following qualifier expression:</p> + <p>This SQL was generated by Cayenne from the <code>ObjectSelect</code> above. <code>ObjectSelect</code> can have a qualifier to select only the data matching specific criteria. Qualifier is simply an Expression (Expressions where discussed in the <a href="/docs/5.0/cayenne-guide/expressions">previous chapter</a>), appended to the query using "where" method. If you only want artists whose name begins with 'Pablo', you might use the following qualifier expression:</p> </div> <div class="listingblock"> <div class="content"> @@ -151,10 +151,10 @@ INFO: === returned 1 row. - took 6 ms.</code></pre> </div> <div class="listingblock"> <div class="content"> - <pre class="highlight"><code class="language-java java" data-lang="java">// this is artificial property signaling that we want to get full object -Property<Artist> artistProperty = Property.createSelf(Artist.class); - -List<Object[]> artistAndPaintingCount = ObjectSelect.columnQuery(Artist.class, artistProperty, Artist.PAINTING_ARRAY.count()) + <pre class="highlight"><code class="language-java java" data-lang="java">// Artist.SELF - is a special property that denotes a full object in this case +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()) @@ -184,17 +184,29 @@ ORDER BY COUNT(t1.PAINTING_ID) DESC, t0.ARTIST_NAME</code></pre> <div class="sect4"> <h5 id="subqueries"><a class="anchor" href="#subqueries"></a>2.6.1.4. Subqueries</h5> <div class="paragraph"> - <p>Since Cayenne 4.2 <code>ObjectSelect</code> supports subqueries. Here is a simple example of <code>NOT EXISTS</code> subquery:</p> + <p>Since Cayenne 4.2 <code>ObjectSelect</code> supports subqueries, and since 5.0 subqueries API is greatly improved. Here is an example of a basic <code>NOT EXISTS</code> subquery:</p> </div> <div class="listingblock"> <div class="content"> - <pre class="highlight"><code class="language-java java" data-lang="java">ObjectSelect<Painting> subQuery = ObjectSelect.query(Painting.class) - .where(Painting.TO_ARTIST.eq(Artist.ARTIST_ID_PK_PROPERTY.enclosing())); -long count = ObjectSelect.query(Artist.class) - .where(ExpressionFactory.notExists(subQuery)) + <pre class="highlight"><code class="language-java java" data-lang="java">long count = ObjectSelect.query(Artist.class) + .where(Artist.PAINTING_ARRAY.notExists()) .selectCount(context);</code></pre> </div> </div> + <div class="paragraph"> + <p>And here’s a generated <code>SQL</code>:</p> + </div> + <div class="listingblock"> + <div class="content"> + <pre class="highlight"><code class="language-SQL SQL" data-lang="SQL">SELECT COUNT( * ) +FROM ARTIST t0 +WHERE + NOT EXISTS (SELECT t1.PAINTING_ID + FROM PAINTING t1 + WHERE t1.ARTIST_ID = t0.ARTIST_ID + )</code></pre> + </div> + </div> </div> </div> <div class="sect3">