Modified: websites/staging/cayenne/trunk/content/docs/4.0/cayenne-guide/queries.html ============================================================================== --- websites/staging/cayenne/trunk/content/docs/4.0/cayenne-guide/queries.html (original) +++ websites/staging/cayenne/trunk/content/docs/4.0/cayenne-guide/queries.html Sat Feb 6 12:02:18 2016 @@ -9,56 +9,58 @@ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); - </script></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div xmlns:d="http://docbook.org/ns/docbook" class="navheader"><table width="100%" summary="Navigation header"><tr><th class="versioninfo">v.4.0 (4.0.M3-SNAPSHOT)</th><th align="center">Chapter 9. Queries</th><th></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="orderings.html">Prev</a> </td><th width="60%" align="center"><a accesskey="u" href="cayenne-guide-part2.html">Part II. Cayenne Framework</a></th><td width="20%" align="right"> <a accesskey="n" href="lifecycle-events.html">Next</a></td></tr></table><hr></div><div class="chapter" title="Chapter 9. Queries"><div class="titlepage"><div><div><h2 class="title"><a name="queries"></a>Chapter 9. Queries</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="queries.html#selectquery">SelectQuery</a></span></dt><d t><span class="section"><a href="queries.html#ejbqlquery">EJBQLQuery</a></span></dt><dt><span class="section"><a href="queries.html#sqltemplate">SQLTemplate</a></span></dt><dt><span class="section"><a href="queries.html#procedurequery">ProcedureQuery</a></span></dt><dt><span class="section"><a href="queries.html#namedquery">NamedQuery</a></span></dt><dt><span class="section"><a href="queries.html#custom-queries">Custom Queries</a></span></dt></dl></div><p>Queries are Java objects used by the application to communicate with the database. Cayenne + </script></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div xmlns:d="http://docbook.org/ns/docbook" class="navheader"><table width="100%" summary="Navigation header"><tr><th class="versioninfo">v.4.0 (4.0.M3-SNAPSHOT)</th><th align="center">Chapter 9. Queries</th><th></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="orderings.html">Prev</a> </td><th width="60%" align="center"><a accesskey="u" href="cayenne-guide-part2.html">Part II. Cayenne Framework</a></th><td width="20%" align="right"> <a accesskey="n" href="lifecycle-events.html">Next</a></td></tr></table><hr></div><div class="chapter" title="Chapter 9. Queries"><div class="titlepage"><div><div><h2 class="title"><a name="queries"></a>Chapter 9. Queries</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="queries.html#selectquery">ObjectSelect</a></span></dt>< dt><span class="section"><a href="queries.html#ejbqlquery">EJBQLQuery</a></span></dt><dt><span class="section"><a href="queries.html#sqltemplate">SQLTemplate</a></span></dt><dt><span class="section"><a href="queries.html#procedurequery">ProcedureQuery</a></span></dt><dt><span class="section"><a href="queries.html#namedquery">NamedQuery</a></span></dt><dt><span class="section"><a href="queries.html#custom-queries">Custom Queries</a></span></dt></dl></div><p>Queries are Java objects used by the application to communicate with the database. Cayenne knows how to translate queries into SQL statements appropriate for a particular database engine. Most often queries are used to find objects matching certain criteria, but there are other types of queries too. E.g. those allowing to run native SQL, call DB stored procedures, etc. When committing objects, Cayenne itself creates special queries to - insert/update/delete rows in the dabase.</p><p>There is a number of built-in queries in Cayenne, described later in this chapter. Users can - also define their own query types to abstract certain DB interactions that for whatever - reason can not be adequately described by the built-in set. </p><p>Queries can be roughly categorized as "object" and "native". Object queries (most notably - SelectQuery and EJBQLQuery) are built with abstractions originating in the object model (the - "object" side in the "object-relational" divide). E.g. SelectQuery is assembled from a Java - class of the objects to fetch, a qualifier expression, orderings, etc. - all of this - expressed in terms of the object model.</p><p>Native queries describe a desired DB operation as SQL code (SQLTemplate query) or a - reference to a stored procedure (ProcedureQuery), etc. The results of native queries are - usually presented as Lists of Maps, with each map representing a row in the DB (a term "data - row" is often used to describe such a map). They can potentially be converted to objects, - however it may take a considerable effort to do so. Native queries are also less (if at all) - portable across databases than object queries. </p><div class="section" title="SelectQuery"><div class="titlepage"><div><div><h2 class="title"><a name="selectquery"></a>SelectQuery</h2></div></div></div><p>SelectQuery is the most commonly used query in user applications. This may be the only - query you will need in most appplications. It returns a list of persistent objects of a - certain type specified in the - query:</p><pre class="programlisting">SelectQuery query = <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>); -List<Artist> objects = context.performQuery(query);</pre><p>This + insert/update/delete rows in the database. </p><p>There is a number of built-in queries in Cayenne, described later in this chapter. Most of + the newer queries use fluent API and can be created and executed as easy-to-read one-liners. + Users can define their own query types to abstract certain DB interactions that for whatever + reason can not be adequately described by the built-in set.</p><p>Queries can be roughly categorized as "object" and "native". Object queries (most notably + ObjectSelect, SelectById, and EJBQLQuery) are built with abstractions originating in the + object model (the "object" side in the "object-relational" divide). E.g. ObjectSelect is + assembled from a Java class of the objects to fetch, a qualifier expression, orderings, etc. + - all of this expressed in terms of the object model.</p><p>Native queries describe a desired DB operation as SQL code (SQLSelect, SQLTemplate query) + or a reference to a stored procedure (ProcedureQuery), etc. The results of native queries + are usually presented as Lists of Maps, with each map representing a row in the DB (a term + "data row" is often used to describe such a map). They can potentially be converted to + objects, however it may take a considerable effort to do so. Native queries are also less + (if at all) portable across databases than object queries. </p><div class="section" title="ObjectSelect"><div class="titlepage"><div><div><h2 class="title"><a name="selectquery"></a>ObjectSelect</h2></div></div></div><p> + <span class="italic">ObjectSelect supersedes older SelectQuery. SelectQuery is still + available and supported. </span> + </p><p>ObjectSelect is the most commonly used query in Cayenne applications. This may be the + only query you will ever need. It returns a list of persistent objects (or data rows) of + a certain type specified in the + query:</p><pre class="programlisting">List<Artist> objects = ObjectSelect.query(Artist.<span xmlns="http://www.w3.org/1999/xhtml" class="hl-keyword">class</span>).select(context);</pre><p>This returned all rows in the "ARTIST" table. If the logs were turned on, you might see the following SQL printed:</p><pre class="programlisting">INFO: SELECT t0.DATE_OF_BIRTH, t0.NAME, t0.ID FROM ARTIST t0 -INFO: === returned <span xmlns="http://www.w3.org/1999/xhtml" class="hl-number">5</span> row. - took <span xmlns="http://www.w3.org/1999/xhtml" class="hl-number">5</span> ms.</pre><p>This SQL was generated by Cayenne from the SelectQuery above. SelectQuery can have a - qualifier to select only the data that you care about. Qualifier is simply an Expression - (Expressions where discussed in the previous chapter). If you only want artists whose - name begins with 'Pablo', you might use the following qualifier expression: - </p><pre class="programlisting">SelectQuery query = <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>, - ExpressionFactory.likeExp(Artist.NAME_PROPERTY, <span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">"Pablo%"</span>)); -List<Artist> objects = context.performQuery(query);</pre><p>The +INFO: === returned <span xmlns="http://www.w3.org/1999/xhtml" class="hl-number">5</span> row. - took <span xmlns="http://www.w3.org/1999/xhtml" class="hl-number">5</span> ms.</pre><p>This SQL was generated by Cayenne from the ObjectSelect above. ObjectSelect 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><pre class="programlisting">List<Artist> objects = ObjectSelect.query(Artist.<span xmlns="http://www.w3.org/1999/xhtml" class="hl-keyword">class</span>) + .where(Artist.NAME.like(<span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">"Pablo%"</span>)) + .select(context);</pre><p>The SQL will look different this time:</p><pre class="programlisting">INFO: SELECT t0.DATE_OF_BIRTH, t0.NAME, t0.ID FROM ARTIST t0 WHERE t0.NAME LIKE ? [bind: <span xmlns="http://www.w3.org/1999/xhtml" class="hl-number">1</span>->NAME:<span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">'Pablo%'</span>] -INFO: === returned <span xmlns="http://www.w3.org/1999/xhtml" class="hl-number">1</span> row. - took <span xmlns="http://www.w3.org/1999/xhtml" class="hl-number">6</span> ms.</pre><p>SelectQuery allows to append parts of qualifier to - self:</p><pre class="programlisting">SelectQuery query = <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>); -query.setQualifier(ExpressionFactory.likeExp(Artist.NAME_PROPERTY, <span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">"A%"</span>)); -query.andQualifier(ExpressionFactory.greaterExp(Artist.DATE_OF_BIRTH_PROPERTY, someDate));</pre><p>To order the results of SelectQuery, one or more Orderings can be applied. Ordering - were already discussed earlier. - E.g.:</p><pre class="programlisting">SelectQuery query = <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>); - -<span xmlns="http://www.w3.org/1999/xhtml" class="hl-comment">// create Ordering object explicitly</span> -query.addOrdering(<span xmlns="http://www.w3.org/1999/xhtml" class="hl-keyword">new</span> Ordering(Artist.DATE_OF_BIRTH_PROPERTY, SortOrder.DESCENDING)); - -<span xmlns="http://www.w3.org/1999/xhtml" class="hl-comment">// or let SelectQuery create it behind the scenes</span> -query.addOrdering(Artist.NAME_PROPERTY, SortOrder.ASCENDING);</pre><p>There's a number of other useful properties in SelectQuery that define what to select +INFO: === returned <span xmlns="http://www.w3.org/1999/xhtml" class="hl-number">1</span> row. - took <span xmlns="http://www.w3.org/1999/xhtml" class="hl-number">6</span> ms.</pre><p>ObjectSelect allows to assemble qualifier from parts, using "and" and "or" method to + chain then + together:</p><pre class="programlisting">List<Artist> objects = ObjectSelect.query(Artist.<span xmlns="http://www.w3.org/1999/xhtml" class="hl-keyword">class</span>) + .where(Artist.NAME.like(<span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">"A%"</span>)) + .and(Artist.DATE_OF_BIRTH.gt(someDate) + .select(context);</pre><p>To order the results of ObjectSelect, one or more orderings can be + applied:</p><pre class="programlisting">List<Artist> objects = ObjectSelect.query(Artist.<span xmlns="http://www.w3.org/1999/xhtml" class="hl-keyword">class</span>) + .addOrderBy(Artist.DATE_OF_BIRTH.desc()) + .addOrderBy(Artist.NAME.asc()) + .select(context);</pre><p>There's a number of other useful methods in ObjectSelect that define what to select and how to optimize database interaction (prefetching, caching, fetch offset and limit, pagination, etc.). Some of them are discussed in separate chapters on caching and performance optimization. Others are fairly self-explanatory. Please check the API docs - for the full extent of the SelectQuery features.</p></div><div class="section" title="EJBQLQuery"><div class="titlepage"><div><div><h2 class="title"><a name="ejbqlquery"></a>EJBQLQuery</h2></div></div></div><p>EJBQLQuery was created as a part of an experiment in adopting some of Java Persistence + for the full extent of the ObjectSelect features.</p></div><div class="section" title="EJBQLQuery"><div class="titlepage"><div><div><h2 class="title"><a name="ejbqlquery"></a>EJBQLQuery</h2></div></div></div><p>EJBQLQuery was created as a part of an experiment in adopting some of Java Persistence API (JPA) approaches in Cayenne. It is a parameterized object query that is created from query String. A String used to build EJBQLQuery must conform to JPQL (JPA query language):</p><pre class="programlisting">EJBQLQuery query = <span xmlns="http://www.w3.org/1999/xhtml" class="hl-keyword">new</span> EJBQLQuery(<span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">"select a FROM Artist a"</span>);</pre><p>JPQL details can be found in any JPA manual. Here we'll mention only how this fits @@ -109,7 +111,7 @@ List<String> names = context.perfo an <a class="link" href="expressions.html" title="Chapter 7. Expressions">Expression</a> object used with a - <a class="link" href="queries.html#selectquery" title="SelectQuery">SelectQuery</a> + <a class="link" href="queries.html#selectquery" title="ObjectSelect">SelectQuery</a> to EJBQL. Use the Expression#appendAsEJBQL methods for this purpose. </p><p> @@ -180,7 +182,7 @@ query.setParameters(Collections.singleto E.g. passing a date object in a WHERE clause expression may be converted to a String not understood by the target RDBMS SQL parser. In such cases variable should be wrapped in <code class="code">#bind</code> directive as described below.</p></div><div class="section" title="Directives"><div class="titlepage"><div><div><h3 class="title"><a name="sqltemplate-bind-directive"></a>Directives</h3></div></div></div><p>These are the Cayenne directives used to customize SQLTemplate parsing and - integrate it with the JDBC layer: </p><div class="section" title="#bind"><div class="titlepage"><div><div><h4 class="title"><a name="d0e1770"></a>#bind</h4></div></div></div><p>Creates a PreparedStatement positional parameter in place of the directive, + integrate it with the JDBC layer: </p><div class="section" title="#bind"><div class="titlepage"><div><div><h4 class="title"><a name="d0e1775"></a>#bind</h4></div></div></div><p>Creates a PreparedStatement positional parameter in place of the directive, binding the value to it before statement execution. <code class="code">#bind</code> is allowed in places where a "?" would be allowed in a PreparedStatement. And in such places it almost always makes sense to pass objects to the template via @@ -199,7 +201,7 @@ query.setParameters(Collections.singleto #bind(<span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">'str'</span>) #bind($xyz <span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">'VARCHAR'</span>) #bind($xyz <span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">'DECIMAL'</span> <span xmlns="http://www.w3.org/1999/xhtml" class="hl-number">2</span>)</pre><p><span class="italic">Full - example:</span></p><pre class="programlisting">update ARTIST set NAME = #bind($name) where ID = #bind($id)</pre></div><div class="section" title="#bindEqual"><div class="titlepage"><div><div><h4 class="title"><a name="d0e1821"></a>#bindEqual</h4></div></div></div><p>Same as #bind, but also includes the "=" sign in front of the value binding. + example:</span></p><pre class="programlisting">update ARTIST set NAME = #bind($name) where ID = #bind($id)</pre></div><div class="section" title="#bindEqual"><div class="titlepage"><div><div><h4 class="title"><a name="d0e1826"></a>#bindEqual</h4></div></div></div><p>Same as #bind, but also includes the "=" sign in front of the value binding. Look at the example below - we took the #bind example and replaced "<code class="code">ID = #bind(..)</code>" with "<code class="code">ID #bindEqual(..)</code>". While it looks like a clumsy shortcut to eliminate the equal sign, the actual reason why this is @@ -214,7 +216,7 @@ query.setParameters(Collections.singleto #bindEqual(<span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">'str'</span>) #bindEqual($xyz <span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">'VARCHAR'</span>) #bindEqual($xyz <span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">'DECIMAL'</span> <span xmlns="http://www.w3.org/1999/xhtml" class="hl-number">2</span>)</pre><p><span class="italic">Full - example:</span></p><pre class="programlisting">update ARTIST set NAME = #bind($name) where ID #bindEqual($id)</pre></div><div class="section" title="#bindNotEqual"><div class="titlepage"><div><div><h4 class="title"><a name="d0e1859"></a>#bindNotEqual</h4></div></div></div><p>This directive deals with the same issue as <code class="code">#bindEqual</code> above, + example:</span></p><pre class="programlisting">update ARTIST set NAME = #bind($name) where ID #bindEqual($id)</pre></div><div class="section" title="#bindNotEqual"><div class="titlepage"><div><div><h4 class="title"><a name="d0e1864"></a>#bindNotEqual</h4></div></div></div><p>This directive deals with the same issue as <code class="code">#bindEqual</code> above, only it generates "not equal" in front of the value (or IS NOT NULL).</p><p><span class="italic">Semantics:</span></p><pre class="programlisting">#bindNotEqual(value) #bindNotEqual(value jdbcType) #bindNotEqual(value jdbcType scale)</pre><p><span class="italic">Arguments: (same as #bind)</span></p><p> @@ -222,7 +224,7 @@ query.setParameters(Collections.singleto #bindNotEqual(<span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">'str'</span>) #bindNotEqual($xyz <span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">'VARCHAR'</span>) #bindNotEqual($xyz <span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">'DECIMAL'</span> <span xmlns="http://www.w3.org/1999/xhtml" class="hl-number">2</span>)</pre><p><span class="italic">Full - example:</span></p><pre class="programlisting">update ARTIST set NAME = #bind($name) where ID #bindEqual($id)</pre></div><div class="section" title="#bindObjectEqual"><div class="titlepage"><div><div><h4 class="title"><a name="d0e1887"></a>#bindObjectEqual</h4></div></div></div><p>It can be tricky to use a Persistent object or an ObjectId in a binding, + example:</span></p><pre class="programlisting">update ARTIST set NAME = #bind($name) where ID #bindEqual($id)</pre></div><div class="section" title="#bindObjectEqual"><div class="titlepage"><div><div><h4 class="title"><a name="d0e1892"></a>#bindObjectEqual</h4></div></div></div><p>It can be tricky to use a Persistent object or an ObjectId in a binding, especially for tables with compound primary keys. This directive helps to handle such binding. It maps columns in the query to the names of Persistent object ID columns, extracts ID values from the object, and generates SQL like "COL1 = ? @@ -239,7 +241,7 @@ query.setParameters(Collections.singleto SQLTemplate select = <span xmlns="http://www.w3.org/1999/xhtml" class="hl-keyword">new</span> SQLTemplate(Artist.<span xmlns="http://www.w3.org/1999/xhtml" class="hl-keyword">class</span>, sql); Artist a = .... -select.setParameters(Collections.singletonMap(<span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">"a"</span>, a)); </pre></div><div class="section" title="#bindObjectNotEqual"><div class="titlepage"><div><div><h4 class="title"><a name="d0e1929"></a>#bindObjectNotEqual</h4></div></div></div><p>Same as #bindObjectEqual above, only generates "not equal" operator for value +select.setParameters(Collections.singletonMap(<span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">"a"</span>, a)); </pre></div><div class="section" title="#bindObjectNotEqual"><div class="titlepage"><div><div><h4 class="title"><a name="d0e1934"></a>#bindObjectNotEqual</h4></div></div></div><p>Same as #bindObjectEqual above, only generates "not equal" operator for value comparison (or IS NOT NULL).</p><p><span class="italic">Semantics:</span></p><pre class="programlisting">#bindObjectNotEqual(value columns idColumns)</pre><p><span class="italic">Arguments: (same as #bindObjectEqual)</span> </p><p> <span class="italic">Usage</span>:</p><pre class="programlisting">#bindObjectNotEqual($a <span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">'t0.ID'</span> <span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">'ID'</span>) @@ -248,7 +250,7 @@ select.setParameters(Collections.singlet SQLTemplate select = <span xmlns="http://www.w3.org/1999/xhtml" class="hl-keyword">new</span> SQLTemplate(Artist.<span xmlns="http://www.w3.org/1999/xhtml" class="hl-keyword">class</span>, sql); Artist a = .... -select.setParameters(Collections.singletonMap(<span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">"a"</span>, a)); </pre></div><div class="section" title="#result"><div class="titlepage"><div><div><h4 class="title"><a name="d0e1955"></a>#result</h4></div></div></div><p>Renders a column in SELECT clause of a query and maps it to a key in the +select.setParameters(Collections.singletonMap(<span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">"a"</span>, a)); </pre></div><div class="section" title="#result"><div class="titlepage"><div><div><h4 class="title"><a name="d0e1960"></a>#result</h4></div></div></div><p>Renders a column in SELECT clause of a query and maps it to a key in the result DataRow. Also ensures the value read is of the correct type. This allows to create a DataRow (and ultimately - a persistent object) from an arbitrary ResultSet.</p><p><span class="italic">Semantics:</span></p><pre class="programlisting">#result(column) @@ -275,7 +277,7 @@ select.setParameters(Collections.singlet #result(<span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">'DOB'</span> <span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">'java.util.Date'</span> <span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">'DATE_OF_BIRTH'</span>) #result(<span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">'DOB'</span> <span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">'java.util.Date'</span> <span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">''</span> <span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">'artist.DATE_OF_BIRTH'</span>) #result(<span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">'SALARY'</span> <span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">'float'</span>) </pre><p><span class="italic">Full - example:</span></p><pre class="programlisting">SELECT #result(<span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">'ID'</span> <span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">'int'</span>), #result(<span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">'NAME'</span> <span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">'String'</span>), #result(<span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">'DATE_OF_BIRTH'</span> <span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">'java.util.Date'</span>) FROM ARTIST</pre></div><div class="section" title="#chain and #chunk"><div class="titlepage"><div><div><h4 class="title"><a name="d0e2011"></a>#chain and #chunk</h4></div></div></div><p><code class="code">#chain</code> and <code class="code">#chunk</code> directives are used for + example:</span></p><pre class="programlisting">SELECT #result(<span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">'ID'</span> <span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">'int'</span>), #result(<span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">'NAME'</span> <span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">'String'</span>), #result(<span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">'DATE_OF_BIRTH'</span> <span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">'java.util.Date'</span>) FROM ARTIST</pre></div><div class="section" title="#chain and #chunk"><div class="titlepage"><div><div><h4 class="title"><a name="d0e2016"></a>#chain and #chunk</h4></div></div></div><p><code class="code">#chain</code> and <code class="code">#chunk</code> directives are used for conditional inclusion of SQL code. They are used together with <code class="code">#chain</code> wrapping multiple <code class="code">#chunks</code>. A chunk evaluates its parameter expression and if it is NULL suppresses rendering of the @@ -293,7 +295,7 @@ select.setParameters(Collections.singlet example:</span></p><pre class="programlisting">#chain(<span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">'OR'</span> <span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">'WHERE'</span>) #chunk($name) NAME LIKE #bind($name) #end<span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">" </span> #chunk($id) ARTIST_ID > #bind($id) #end<span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">" -</span>#end<span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">" </span></pre></div></div><div class="section" title="Mapping SQLTemplate Results"><div class="titlepage"><div><div><h3 class="title"><a name="d0e2039"></a>Mapping SQLTemplate Results</h3></div></div></div><p>Here we'll discuss how to convert the data selected via SQLTemplate to some +</span>#end<span xmlns="http://www.w3.org/1999/xhtml" class="hl-string">" </span></pre></div></div><div class="section" title="Mapping SQLTemplate Results"><div class="titlepage"><div><div><h3 class="title"><a name="d0e2044"></a>Mapping SQLTemplate Results</h3></div></div></div><p>Here we'll discuss how to convert the data selected via SQLTemplate to some useable format, compatible with other query results. It can either be very simple or very complex, depending on the structure of the SQL, JDBC driver nature and the desired result structure. This section presents various tips and tricks dealing with
Modified: websites/staging/cayenne/trunk/content/docs/4.0/cayenne-guide/service-collections.html ============================================================================== --- websites/staging/cayenne/trunk/content/docs/4.0/cayenne-guide/service-collections.html (original) +++ websites/staging/cayenne/trunk/content/docs/4.0/cayenne-guide/service-collections.html Sat Feb 6 12:02:18 2016 @@ -12,7 +12,7 @@ </script></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div xmlns:d="http://docbook.org/ns/docbook" class="navheader"><table width="100%" summary="Navigation header"><tr><th class="versioninfo">v.4.0 (4.0.M3-SNAPSHOT)</th><th align="center">Appendix B. Service Collections</th><th></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="configuration-properties.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="expressions-bnf.html">Next</a></td></tr></table><hr></div><div class="appendix" title="Appendix B. Service Collections"><div class="titlepage"><div><div><h2 class="title"><a name="service-collections"></a>Appendix B. Service Collections</h2></div></div></div><p>Note that the collection keys below are defined as constants in <code class="code">org.apache.cayenne.configuration.Constants</code> interface.</p><p> - </p><table frame="void" id="d0e3135"><caption>Table B.1. Service Collection Keys Present in ServerRuntime and/or ClientRuntime</caption><col width="42%"><col width="25%"><col width="33%"><thead><tr> + </p><table frame="void" id="d0e3239"><caption>Table B.1. Service Collection Keys Present in ServerRuntime and/or ClientRuntime</caption><col width="42%"><col width="25%"><col width="33%"><thead><tr> <th>Collection Property</th> <th>Type</th> <th>Description</th> Modified: websites/staging/cayenne/trunk/content/docs/4.0/cayenne-guide/setup.html ============================================================================== --- websites/staging/cayenne/trunk/content/docs/4.0/cayenne-guide/setup.html (original) +++ websites/staging/cayenne/trunk/content/docs/4.0/cayenne-guide/setup.html Sat Feb 6 12:02:18 2016 @@ -19,7 +19,7 @@ <th>Status</th> </tr><tr> <td>4.0</td> - <td>Java 1.6 or newer</td> + <td>Java 1.7 or newer</td> <td>Alpha (in development)</td> </tr><tr> <td>3.1</td>