cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r405581 [12/14] - in /incubator/cayenne/main/trunk/cayenne/cayenne-other: docs/ docs/images/ wiki-docs/ wiki-docs/Documentation/ wiki-docs/Documentation/Modeler Guide/ wiki-docs/Documentation/Modeler Guide/Cayenne Project Structure/ wiki-do...
Date Wed, 10 May 2006 01:11:01 GMT
Added: incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User Guide/Queries/Customizing Queries/index.html
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User%20Guide/Queries/Customizing%20Queries/index.html?rev=405581&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User Guide/Queries/Customizing Queries/index.html (added)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User Guide/Queries/Customizing Queries/index.html Tue May  9 18:10:42 2006
@@ -0,0 +1,145 @@
+<html>
+  <head>
+    <title>Cayenne Documentation - Customizing Queries</title>
+    <style type="text/css">@import "../../../../style.css";</style>
+  </head>
+<body>
+  <div class="header">
+    <div style="float: left;"><a href="http://objectstyle.org/cayenne/"><img src="../../../../images/logo.gif" align="absmiddle" border="0"></a></div>
+    <span class="logoSpaceLink"><a href="../../../../index.html">Cayenne User Documentation</a></span><br />
+    <span class="pagetitle">Customizing Queries</span>
+  </div>
+<div id="cayenne_toc">
+<ul>
+<li><a href="../../../../Documentation/User Guide/Introduction/index.html">Introduction</a></li>
+<li><a href="../../../../Documentation/User Guide/Installation/index.html">Installation</a></li>
+<li><a href="../../../../Documentation/User Guide/Quick Start/index.html">Quick Start</a></li>
+<li><a href="../../../../Documentation/User Guide/Design/index.html">Design</a></li>
+<li><a href="../../../../Documentation/User Guide/Generating Classes/index.html">Generating Classes</a></li>
+<li><a href="../../../../Documentation/User Guide/DataContext/index.html">DataContext</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/index.html">Queries</a><ul>
+<li><a href="../../../../Documentation/User Guide/Queries/Caching Query Results/index.html">Caching Query Results</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Customizing Queries/index.html">Customizing Queries</a><ul>
+</ul>
+</li>
+<li><a href="../../../../Documentation/User Guide/Queries/NamedQuery/index.html">NamedQuery</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/ObjectIdQuery/index.html">ObjectIdQuery</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Parameterized Queries/index.html">Parameterized Queries</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Qualifier Expressions/index.html">Qualifier Expressions</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Queries Stored in DataMap/index.html">Queries Stored in DataMap</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/QueryChain/index.html">QueryChain</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/RelationshipQuery/index.html">RelationshipQuery</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/SQLTemplate Query/index.html">SQLTemplate Query</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Scripting SQLTemplate/index.html">Scripting SQLTemplate</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/SelectQuery/index.html">SelectQuery</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/SelectQuery Customization/index.html">SelectQuery Customization</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Using Orderings/index.html">Using Orderings</a></li>
+</ul>
+</li>
+<li><a href="../../../../Documentation/User Guide/DataObjects/index.html">DataObjects</a></li>
+<li><a href="../../../../Documentation/User Guide/Stored Procedures/index.html">Stored Procedures</a></li>
+<li><a href="../../../../Documentation/User Guide/Expressions/index.html">Expressions</a></li>
+<li><a href="../../../../Documentation/User Guide/Performance Tuning/index.html">Performance Tuning</a></li>
+<li><a href="../../../../Documentation/User Guide/Deployment/index.html">Deployment</a></li>
+<li><a href="../../../../Documentation/User Guide/Ant Tasks/index.html">Ant Tasks</a></li>
+<li><a href="../../../../Documentation/User Guide/Access Stack Internals/index.html">Access Stack Internals</a></li>
+<li><a href="../../../../Documentation/User Guide/DataViews/index.html">DataViews</a></li>
+</ul>
+</div>
+<div id="ConfluenceContent"><p>Any object that implements <tt>org.objectstyle.cayenne.query.Query</tt> interface can be executed with a DataContext. </p>
+
+<h3><a name="CustomizingQueries-UnderstandingQueryInterface"></a>Understanding Query Interface</h3>
+
+<p>The interface defines the following methods (ommitting irrelevant deprecated ones):</p>
+
+<div class="code"><div class="codeContent">
+<pre class="code-java"><span class="code-keyword">public</span> <span class="code-keyword">interface</span> Query <span class="code-keyword">extends</span> Serializable {
+
+    <span class="code-object">String</span> getName();
+
+    QueryMetadata getMetaData(EntityResolver resolver);
+
+    void route(QueryRouter router, EntityResolver resolver, Query substitutedQuery);
+
+    SQLAction createSQLAction(SQLActionVisitor visitor);
+}</pre>
+</div></div>
+
+<ul>
+	<li><tt>getName</tt> returns a symbolic name of the query. The name may be used as a key to find queries stored in the DataMap. Some query implementors reuse the name as a QueryMetadata cache key. Generally the name can be null.</li>
+</ul>
+
+
+<ul>
+	<li><tt>getMetaData</tt> is called at various stages of the execution by Cayenne access stack to retrieve query parameters. <tt>EntityResolver</tt> instance is passed to this method, meaning that the query doesn't need to store direct references to Cayenne mapping objects and can resolve them at runtime.</li>
+</ul>
+
+
+<ul>
+	<li><tt>route</tt> is invoked when Cayenne decides which DataNode (database) to use when running a query. Routing decision is made by the Query istelf by calling <tt>QueryRouter.route(..)</tt>. This is an important extension point. For instance all Cayenne "indirect" queries implement this method to create (or somehow resolve) one or more substitute queries and route them instead of self.</li>
+</ul>
+
+
+<ul>
+	<li><tt>createSQLAction</tt> allows to fully customize Query execution at the JDBC level. In the simplest case an implementor calls one of the methods on <tt>SQLActionVisitor</tt> to return a standard action for a specific type of query. However it can provide its own <tt>SQLAction</tt> that accesses the database in some special way.</li>
+</ul>
+
+
+<h3><a name="CustomizingQueries-IndirectQueries"></a>Indirect Queries</h3>
+
+<p>One customization strategy is an "indirect" query that encapsulates some user-defined operation and in runtime resolves to one or more standard Cayenne queries. Indirect queries can be created from scratch or by extending <tt>org.objectstyle.cayenne.query.IndirectQuery</tt>. As an example lets implement a "CountQuery" query that returns a number of rows in a given table:</p>
+
+<div class="code"><div class="codeContent">
+<pre class="code-java"><span class="code-keyword">public</span> class CountQuery <span class="code-keyword">extends</span> IndirectQuery {
+	<span class="code-keyword">protected</span> <span class="code-object">Class</span> objectClass;
+
+	<span class="code-keyword">public</span> CountQuery(<span class="code-object">Class</span> objectClass) {
+		<span class="code-keyword">this</span>.objectClass = objectClass;
+	}
+
+	<span class="code-keyword">protected</span> Query createReplacementQuery(EntityResolver resolver) {
+		DbEntity entity = resolver.lookupDbEntity(objectClass);
+
+		<span class="code-keyword">if</span> (entity == <span class="code-keyword">null</span>) {
+			<span class="code-keyword">throw</span> <span class="code-keyword">new</span> CayenneRuntimeException(
+					<span class="code-quote">"No entity is mapped <span class="code-keyword">for</span> java class: "</span>
+							+ objectClass.getName());
+		}
+
+		<span class="code-object">String</span> sql = <span class="code-quote">"SELECT #result('count(*)' '<span class="code-object">int</span>' 'C') FROM "</span>
+				+ entity.getName();
+		SQLTemplate replacement = <span class="code-keyword">new</span> SQLTemplate(entity, sql);
+		replacement.setFetchingDataRows(<span class="code-keyword">true</span>);
+		<span class="code-keyword">return</span> replacement;
+	}
+}</pre>
+</div></div>
+
+<p>Now you can run the query like that:</p>
+
+<div class="code"><div class="codeContent">
+<pre class="code-java">CountQuery query = <span class="code-keyword">new</span> CountQuery(Artist.class);
+DataContext context = DataContext.createDataContext();
+
+Map row = (Map) context.performQuery(query).get(0);
+<span class="code-object">System</span>.out.println(<span class="code-quote">"Count: "</span> + row.get(<span class="code-quote">"C"</span>));</pre>
+</div></div>
+
+
+<p>For other real-life examples of indirect queries take a look at the source code of the following Cayenne queries: <a href="../../../../Documentation/User Guide/Queries/QueryChain/index.html" title="QueryChain">QueryChain</a>, <a href="../../../../Documentation/User Guide/Queries/ObjectIdQuery/index.html" title="ObjectIdQuery">ObjectIdQuery</a>, <a href="../../../../Documentation/User Guide/Queries/RelationshipQuery/index.html" title="RelationshipQuery">RelationshipQuery</a>, <a href="../../../../Documentation/User Guide/Queries/NamedQuery/index.html" title="NamedQuery">NamedQuery</a>. </p>
+
+
+<h3><a name="CustomizingQueries-SubclassingStandardQueries"></a>Subclassing Standard Queries</h3>
+
+<p>All standard queries can be subclassed, overriding some of their methods. For instance overriding <tt>route</tt> and/or <tt>createSQLAction</tt> would allow to implement custom callbacks at different points of query lifecycle.</p>
+</div>
+</div>
+  <div class="clearer">.</div>
+  <div style="height: 12px; background-image: url('../../../../images/border_bottom.gif'); background-repeat: repeat-x;"></div>
+
+  <div class="smalltext copyright">
+    Copyright &copy;2001-2006 ObjectStyle Group and content authors
+  </div>
+
+</body>
+</html>

Propchange: incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User Guide/Queries/Customizing Queries/index.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User Guide/Queries/NamedQuery/index.html
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User%20Guide/Queries/NamedQuery/index.html?rev=405581&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User Guide/Queries/NamedQuery/index.html (added)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User Guide/Queries/NamedQuery/index.html Tue May  9 18:10:42 2006
@@ -0,0 +1,70 @@
+<html>
+  <head>
+    <title>Cayenne Documentation - NamedQuery</title>
+    <style type="text/css">@import "../../../../style.css";</style>
+  </head>
+<body>
+  <div class="header">
+    <div style="float: left;"><a href="http://objectstyle.org/cayenne/"><img src="../../../../images/logo.gif" align="absmiddle" border="0"></a></div>
+    <span class="logoSpaceLink"><a href="../../../../index.html">Cayenne User Documentation</a></span><br />
+    <span class="pagetitle">NamedQuery</span>
+  </div>
+<div id="cayenne_toc">
+<ul>
+<li><a href="../../../../Documentation/User Guide/Introduction/index.html">Introduction</a></li>
+<li><a href="../../../../Documentation/User Guide/Installation/index.html">Installation</a></li>
+<li><a href="../../../../Documentation/User Guide/Quick Start/index.html">Quick Start</a></li>
+<li><a href="../../../../Documentation/User Guide/Design/index.html">Design</a></li>
+<li><a href="../../../../Documentation/User Guide/Generating Classes/index.html">Generating Classes</a></li>
+<li><a href="../../../../Documentation/User Guide/DataContext/index.html">DataContext</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/index.html">Queries</a><ul>
+<li><a href="../../../../Documentation/User Guide/Queries/Caching Query Results/index.html">Caching Query Results</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Customizing Queries/index.html">Customizing Queries</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/NamedQuery/index.html">NamedQuery</a><ul>
+</ul>
+</li>
+<li><a href="../../../../Documentation/User Guide/Queries/ObjectIdQuery/index.html">ObjectIdQuery</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Parameterized Queries/index.html">Parameterized Queries</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Qualifier Expressions/index.html">Qualifier Expressions</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Queries Stored in DataMap/index.html">Queries Stored in DataMap</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/QueryChain/index.html">QueryChain</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/RelationshipQuery/index.html">RelationshipQuery</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/SQLTemplate Query/index.html">SQLTemplate Query</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Scripting SQLTemplate/index.html">Scripting SQLTemplate</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/SelectQuery/index.html">SelectQuery</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/SelectQuery Customization/index.html">SelectQuery Customization</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Using Orderings/index.html">Using Orderings</a></li>
+</ul>
+</li>
+<li><a href="../../../../Documentation/User Guide/DataObjects/index.html">DataObjects</a></li>
+<li><a href="../../../../Documentation/User Guide/Stored Procedures/index.html">Stored Procedures</a></li>
+<li><a href="../../../../Documentation/User Guide/Expressions/index.html">Expressions</a></li>
+<li><a href="../../../../Documentation/User Guide/Performance Tuning/index.html">Performance Tuning</a></li>
+<li><a href="../../../../Documentation/User Guide/Deployment/index.html">Deployment</a></li>
+<li><a href="../../../../Documentation/User Guide/Ant Tasks/index.html">Ant Tasks</a></li>
+<li><a href="../../../../Documentation/User Guide/Access Stack Internals/index.html">Access Stack Internals</a></li>
+<li><a href="../../../../Documentation/User Guide/DataViews/index.html">DataViews</a></li>
+</ul>
+</div>
+<div id="ConfluenceContent"><p><tt>NamedQuery</tt> is a query that is a reference to another query stored in the DataMap. It can hold named parameters that will be passed to the named query on execution.</p>
+
+<p>Assuming that there a query called "Login" was previously mapped in the Modeler, we can do this:</p>
+
+<div class="code"><div class="codeContent">
+<pre class="code-java"><span class="code-object">String</span>[] keys = <span class="code-keyword">new</span> <span class="code-object">String</span>[] {<span class="code-quote">"loginid"</span>, <span class="code-quote">"password"</span>};
+<span class="code-object">Object</span>[] values = <span class="code-keyword">new</span> <span class="code-object">String</span>[] {<span class="code-quote">"joe"</span>, <span class="code-quote">"secret"</span>};
+
+NamedQuery query = <span class="code-keyword">new</span> NamedQuery(<span class="code-quote">"Login"</span>, keys, values);
+
+List matchingUsers = context.performedQuery(query);</pre>
+</div></div></div>
+</div>
+  <div class="clearer">.</div>
+  <div style="height: 12px; background-image: url('../../../../images/border_bottom.gif'); background-repeat: repeat-x;"></div>
+
+  <div class="smalltext copyright">
+    Copyright &copy;2001-2006 ObjectStyle Group and content authors
+  </div>
+
+</body>
+</html>

Propchange: incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User Guide/Queries/NamedQuery/index.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User Guide/Queries/ObjectIdQuery/index.html
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User%20Guide/Queries/ObjectIdQuery/index.html?rev=405581&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User Guide/Queries/ObjectIdQuery/index.html (added)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User Guide/Queries/ObjectIdQuery/index.html Tue May  9 18:10:42 2006
@@ -0,0 +1,110 @@
+<html>
+  <head>
+    <title>Cayenne Documentation - ObjectIdQuery</title>
+    <style type="text/css">@import "../../../../style.css";</style>
+  </head>
+<body>
+  <div class="header">
+    <div style="float: left;"><a href="http://objectstyle.org/cayenne/"><img src="../../../../images/logo.gif" align="absmiddle" border="0"></a></div>
+    <span class="logoSpaceLink"><a href="../../../../index.html">Cayenne User Documentation</a></span><br />
+    <span class="pagetitle">ObjectIdQuery</span>
+  </div>
+<div id="cayenne_toc">
+<ul>
+<li><a href="../../../../Documentation/User Guide/Introduction/index.html">Introduction</a></li>
+<li><a href="../../../../Documentation/User Guide/Installation/index.html">Installation</a></li>
+<li><a href="../../../../Documentation/User Guide/Quick Start/index.html">Quick Start</a></li>
+<li><a href="../../../../Documentation/User Guide/Design/index.html">Design</a></li>
+<li><a href="../../../../Documentation/User Guide/Generating Classes/index.html">Generating Classes</a></li>
+<li><a href="../../../../Documentation/User Guide/DataContext/index.html">DataContext</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/index.html">Queries</a><ul>
+<li><a href="../../../../Documentation/User Guide/Queries/Caching Query Results/index.html">Caching Query Results</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Customizing Queries/index.html">Customizing Queries</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/NamedQuery/index.html">NamedQuery</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/ObjectIdQuery/index.html">ObjectIdQuery</a><ul>
+</ul>
+</li>
+<li><a href="../../../../Documentation/User Guide/Queries/Parameterized Queries/index.html">Parameterized Queries</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Qualifier Expressions/index.html">Qualifier Expressions</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Queries Stored in DataMap/index.html">Queries Stored in DataMap</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/QueryChain/index.html">QueryChain</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/RelationshipQuery/index.html">RelationshipQuery</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/SQLTemplate Query/index.html">SQLTemplate Query</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Scripting SQLTemplate/index.html">Scripting SQLTemplate</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/SelectQuery/index.html">SelectQuery</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/SelectQuery Customization/index.html">SelectQuery Customization</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Using Orderings/index.html">Using Orderings</a></li>
+</ul>
+</li>
+<li><a href="../../../../Documentation/User Guide/DataObjects/index.html">DataObjects</a></li>
+<li><a href="../../../../Documentation/User Guide/Stored Procedures/index.html">Stored Procedures</a></li>
+<li><a href="../../../../Documentation/User Guide/Expressions/index.html">Expressions</a></li>
+<li><a href="../../../../Documentation/User Guide/Performance Tuning/index.html">Performance Tuning</a></li>
+<li><a href="../../../../Documentation/User Guide/Deployment/index.html">Deployment</a></li>
+<li><a href="../../../../Documentation/User Guide/Ant Tasks/index.html">Ant Tasks</a></li>
+<li><a href="../../../../Documentation/User Guide/Access Stack Internals/index.html">Access Stack Internals</a></li>
+<li><a href="../../../../Documentation/User Guide/DataViews/index.html">DataViews</a></li>
+</ul>
+</div>
+<div id="ConfluenceContent"><p><em>(DataObjectUtils API below is available since 1.2M10. SingleObjectQuery, a precursor of ObjectIdQuery, was available since 1.2M9. In 1.2M12 SingleObjectQuery was renamed to ObjectIdQuery)</em></p>
+
+<p><tt>ObjectIdQuery</tt> is a query that selects objects matching an ObjectId. Considering that ObjectId must be unique, the result of such query is a single object or no objects.</p>
+
+<p>Normally if you need to find an object that matches a certain primary key value, you would use <tt>DataObjectUtils.objectForPK(DataContext,String,int)</tt>. This method will look up an object in the cache, and only run a query if it is not yet cached. <tt>ObjectIdQuery</tt> gives the user more control of the object caching behavior. It supports three possible caching policies:</p>
+
+<table class='confluenceTable'><tbody>
+<tr>
+<th class='confluenceTh'>Policy</th>
+<th class='confluenceTh'>Cache Behavior</th>
+</tr>
+<tr>
+<td class='confluenceTd'><tt>ObjectIdQuery.CACHE</tt> </td>
+<td class='confluenceTd'>This policy is similar to DataObjectUtils behavior. If an object is already cached (either at the DataContext or DataDomain level), it is returned, otherwise the fetch is performed.</td>
+</tr>
+<tr>
+<td class='confluenceTd'><em>(default policy)</em> <tt>ObjectIdQuery.CACHE_REFRESH</tt> </td>
+<td class='confluenceTd'>This policy forces a database fetch. If an object is already cached (either at the DataContext or DataDomain level), cache is refreshed with a new version and a fresh object is included in the result.</td>
+</tr>
+<tr>
+<td class='confluenceTd'><tt>ObjectIdQuery.CACHE_NO_REFRESH</tt> </td>
+<td class='confluenceTd'>This policy suppresses database fetch. If an object is already cached (either at the DataContext or DataDomain level), query returns this object. Otherwise it returns an empty result.</td>
+</tr>
+</tbody></table>
+
+<p>An example of getting a guranteed fresh object:</p>
+
+<div class="code"><div class="codeContent">
+<pre class="code-java">ObjectId id = <span class="code-keyword">new</span> ObjectId(<span class="code-quote">"Artist"</span>, Artist.ARTIST_ID_PK_COLUMN, 55);
+
+<span class="code-comment">// <span class="code-keyword">this</span> constructor implicitly uses <span class="code-quote">"CACHE_REFRESH"</span> policy, so a fresh object will be returned
+</span>ObjectIdQuery query = <span class="code-keyword">new</span> ObjectIdQuery(id);
+
+DataContext context = ...
+Artist object = (Artist) DataObjectUtils.objectForQuery(context, query);</pre>
+</div></div>
+
+<p>An example of checking whether an object is already cached:</p>
+
+<div class="code"><div class="codeContent">
+<pre class="code-java">ObjectId id = <span class="code-keyword">new</span> ObjectId(<span class="code-quote">"Artist"</span>, Artist.ARTIST_ID_PK_COLUMN, 55);
+ObjectIdQuery query = <span class="code-keyword">new</span> ObjectIdQuery(id, <span class="code-keyword">false</span>, ObjectIdQuery.CACHE_NO_REFRESH);
+
+DataContext context = ...
+Artist object = (Artist) DataObjectUtils.objectForQuery(context, query);
+<span class="code-keyword">if</span>(object == <span class="code-keyword">null</span>) {
+  <span class="code-comment">// not cached
+</span>}
+<span class="code-keyword">else</span> {
+  <span class="code-comment">// cached
+</span>}</pre>
+</div></div></div>
+</div>
+  <div class="clearer">.</div>
+  <div style="height: 12px; background-image: url('../../../../images/border_bottom.gif'); background-repeat: repeat-x;"></div>
+
+  <div class="smalltext copyright">
+    Copyright &copy;2001-2006 ObjectStyle Group and content authors
+  </div>
+
+</body>
+</html>

Propchange: incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User Guide/Queries/ObjectIdQuery/index.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User Guide/Queries/Parameterized Queries/index.html
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User%20Guide/Queries/Parameterized%20Queries/index.html?rev=405581&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User Guide/Queries/Parameterized Queries/index.html (added)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User Guide/Queries/Parameterized Queries/index.html Tue May  9 18:10:42 2006
@@ -0,0 +1,132 @@
+<html>
+  <head>
+    <title>Cayenne Documentation - Parameterized Queries</title>
+    <style type="text/css">@import "../../../../style.css";</style>
+  </head>
+<body>
+  <div class="header">
+    <div style="float: left;"><a href="http://objectstyle.org/cayenne/"><img src="../../../../images/logo.gif" align="absmiddle" border="0"></a></div>
+    <span class="logoSpaceLink"><a href="../../../../index.html">Cayenne User Documentation</a></span><br />
+    <span class="pagetitle">Parameterized Queries</span>
+  </div>
+<div id="cayenne_toc">
+<ul>
+<li><a href="../../../../Documentation/User Guide/Introduction/index.html">Introduction</a></li>
+<li><a href="../../../../Documentation/User Guide/Installation/index.html">Installation</a></li>
+<li><a href="../../../../Documentation/User Guide/Quick Start/index.html">Quick Start</a></li>
+<li><a href="../../../../Documentation/User Guide/Design/index.html">Design</a></li>
+<li><a href="../../../../Documentation/User Guide/Generating Classes/index.html">Generating Classes</a></li>
+<li><a href="../../../../Documentation/User Guide/DataContext/index.html">DataContext</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/index.html">Queries</a><ul>
+<li><a href="../../../../Documentation/User Guide/Queries/Caching Query Results/index.html">Caching Query Results</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Customizing Queries/index.html">Customizing Queries</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/NamedQuery/index.html">NamedQuery</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/ObjectIdQuery/index.html">ObjectIdQuery</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Parameterized Queries/index.html">Parameterized Queries</a><ul>
+</ul>
+</li>
+<li><a href="../../../../Documentation/User Guide/Queries/Qualifier Expressions/index.html">Qualifier Expressions</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Queries Stored in DataMap/index.html">Queries Stored in DataMap</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/QueryChain/index.html">QueryChain</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/RelationshipQuery/index.html">RelationshipQuery</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/SQLTemplate Query/index.html">SQLTemplate Query</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Scripting SQLTemplate/index.html">Scripting SQLTemplate</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/SelectQuery/index.html">SelectQuery</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/SelectQuery Customization/index.html">SelectQuery Customization</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Using Orderings/index.html">Using Orderings</a></li>
+</ul>
+</li>
+<li><a href="../../../../Documentation/User Guide/DataObjects/index.html">DataObjects</a></li>
+<li><a href="../../../../Documentation/User Guide/Stored Procedures/index.html">Stored Procedures</a></li>
+<li><a href="../../../../Documentation/User Guide/Expressions/index.html">Expressions</a></li>
+<li><a href="../../../../Documentation/User Guide/Performance Tuning/index.html">Performance Tuning</a></li>
+<li><a href="../../../../Documentation/User Guide/Deployment/index.html">Deployment</a></li>
+<li><a href="../../../../Documentation/User Guide/Ant Tasks/index.html">Ant Tasks</a></li>
+<li><a href="../../../../Documentation/User Guide/Access Stack Internals/index.html">Access Stack Internals</a></li>
+<li><a href="../../../../Documentation/User Guide/DataViews/index.html">DataViews</a></li>
+</ul>
+</div>
+<div id="ConfluenceContent"><p>SelectQuery objects can be rather complex. They may contain long qualifiers and lots of tuning parameters. Parameterized Queries feature addresses reusability of complex queries. With this feature, for each group of queries that differ only in the values used in the qualifier, a developer may create a single shared "prototype" or "template" query, and use it later as a factory for other queries. All settings configured in the prototype object will be passed to the final queries. Qualifier of the prototype query may use named parameters that are substituted for real values when a final query is created from the prototype.</p>
+<table cellpadding='5' width='85%' cellspacing='8px' class='infoMacro' border="0" align='center'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="../../../../images/emoticons/information.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>"Prototype" queries are normally created in CayenneModeler and stored in the DataMap XML file. "Queries Stored in DataMap" chapter describes how to use such templates. This chapter shows how to create them on the spot using the API calls.</td></tr></table>
+
+<p>Building a prototype query using <tt>Expression.fromString(..)</tt>:</p>
+
+<div class="code"><div class="codeContent">
+<pre class="code-java"><span class="code-keyword">import</span> org.objectstyle.cayenne.exp.Expression;
+<span class="code-keyword">import</span> org.objectstyle.cayenne.query.SelectQuery;
+...
+<span class="code-comment">// create a qualifier with two named parameters: <span class="code-quote">"pname"</span> and <span class="code-quote">"aname"</span>
+</span>Expression qual = Expression.fromString(<span class="code-quote">"paintingTitle = $pname or toArtist.artistName = $aname"</span>);
+
+<span class="code-comment">// build a query prototype of a query - simply another select query
+</span>SelectQuery proto = <span class="code-keyword">new</span> SelectQuery(Painting.class, qual);
+proto.setDistinct(<span class="code-keyword">true</span>);</pre>
+</div></div>
+
+<p>Same example but using ExpressionFactory:</p>
+
+<div class="code"><div class="codeContent">
+<pre class="code-java"><span class="code-keyword">import</span> java.util.*;
+<span class="code-keyword">import</span> org.objectstyle.cayenne.exp.Expression;
+<span class="code-keyword">import</span> org.objectstyle.cayenne.exp.ExpressionFactory;
+<span class="code-keyword">import</span> org.objectstyle.cayenne.exp.ExpressionParameter;
+<span class="code-keyword">import</span> org.objectstyle.cayenne.query.SelectQuery;
+...
+<span class="code-comment">// create a qualifier with two named parameters: 
+</span><span class="code-comment">//  <span class="code-quote">"pname"</span> and <span class="code-quote">"aname"</span>
+</span>List list = <span class="code-keyword">new</span> ArrayList();
+list.add(ExpressionFactory.matchExp(<span class="code-quote">"paintingTitle"</span>, 
+         <span class="code-keyword">new</span> ExpressionParameter(<span class="code-quote">"pname"</span>)));
+list.add(ExpressionFactory.matchExp(<span class="code-quote">"toArtist.artistName"</span>, 
+         <span class="code-keyword">new</span> ExpressionParameter(<span class="code-quote">"aname"</span>)));
+Expression qual = ExpressionFactory.joinExp(Expression.OR, list);
+
+<span class="code-comment">// build a query prototype of a query - simply another select query
+</span>SelectQuery proto = <span class="code-keyword">new</span> SelectQuery(Painting.class, qual);
+proto.setDistinct(<span class="code-keyword">true</span>);</pre>
+</div></div>
+<p>Prototype built in the example above can be used to create other queries. Relevalnt API is:</p>
+
+<ul>
+	<li>public SelectQuery <b>SelectQuery.queryWithParameters</b>(Map parameters, boolean pruneMissing)<br/>
+      Creates and returns a new SelectQuery using current query as a prototype. Map of parameters is used to substitute named parameters in the qualifier with the real values. Returned query is a separate instance and can be further customized without affecting the prototype. If <tt>pruneMissing</tt> is true and some of the named parameters are missing from the parameters map, Cayenne would prune expressions that can not be resolved. If pruneMissing is set to false, the method would throw an exception unless all the named parameters can be resolved.</li>
+	<li>public SelectQuery <b>SelectQuery.queryWithParameters</b>(Map parameters)<br/>
+      A shortcut for <tt>public SelectQuery queryWithParameters(Map parameters, true)</tt>.</li>
+</ul>
+
+
+<p>Example of using queryWithParameters is shown below:</p>
+
+<div class="code"><div class="codeContent">
+<pre class="code-java"><span class="code-keyword">import</span> java.util.Map;
+<span class="code-keyword">import</span> java.util.HashMap;
+<span class="code-keyword">import</span> org.objectstyle.cayenne.query.SelectQuery;
+...
+SelectQuery proto = ... <span class="code-comment">// <span class="code-keyword">this</span> was built in the example above
+</span>
+<span class="code-comment">// create a query
+</span>Map params1 = <span class="code-keyword">new</span> HashMap();
+params1.put(<span class="code-quote">"aname"</span>, <span class="code-quote">"Dali"</span>);
+SelectQuery query1 = proto.queryWithParameters(params1);
+
+<span class="code-comment">// further customize returned query 
+</span><span class="code-comment">// without affecting the prototype
+</span>query1.setFetchLimit(100);
+... 
+<span class="code-comment">// create another query with a different set of parameters
+</span>Map params2 = <span class="code-keyword">new</span> HashMap();
+params2.put(<span class="code-quote">"aname"</span>, <span class="code-quote">"Monet"</span>);
+params2.put(<span class="code-quote">"pname"</span>, <span class="code-quote">"The Beach at Trouville"</span>);
+SelectQuery query2 = proto.queryWithParameters(params2);
+...</pre>
+</div></div></div>
+</div>
+  <div class="clearer">.</div>
+  <div style="height: 12px; background-image: url('../../../../images/border_bottom.gif'); background-repeat: repeat-x;"></div>
+
+  <div class="smalltext copyright">
+    Copyright &copy;2001-2006 ObjectStyle Group and content authors
+  </div>
+
+</body>
+</html>

Propchange: incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User Guide/Queries/Parameterized Queries/index.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User Guide/Queries/Qualifier Expressions/index.html
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User%20Guide/Queries/Qualifier%20Expressions/index.html?rev=405581&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User Guide/Queries/Qualifier Expressions/index.html (added)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User Guide/Queries/Qualifier Expressions/index.html Tue May  9 18:10:42 2006
@@ -0,0 +1,75 @@
+<html>
+  <head>
+    <title>Cayenne Documentation - Qualifier Expressions</title>
+    <style type="text/css">@import "../../../../style.css";</style>
+  </head>
+<body>
+  <div class="header">
+    <div style="float: left;"><a href="http://objectstyle.org/cayenne/"><img src="../../../../images/logo.gif" align="absmiddle" border="0"></a></div>
+    <span class="logoSpaceLink"><a href="../../../../index.html">Cayenne User Documentation</a></span><br />
+    <span class="pagetitle">Qualifier Expressions</span>
+  </div>
+<div id="cayenne_toc">
+<ul>
+<li><a href="../../../../Documentation/User Guide/Introduction/index.html">Introduction</a></li>
+<li><a href="../../../../Documentation/User Guide/Installation/index.html">Installation</a></li>
+<li><a href="../../../../Documentation/User Guide/Quick Start/index.html">Quick Start</a></li>
+<li><a href="../../../../Documentation/User Guide/Design/index.html">Design</a></li>
+<li><a href="../../../../Documentation/User Guide/Generating Classes/index.html">Generating Classes</a></li>
+<li><a href="../../../../Documentation/User Guide/DataContext/index.html">DataContext</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/index.html">Queries</a><ul>
+<li><a href="../../../../Documentation/User Guide/Queries/Caching Query Results/index.html">Caching Query Results</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Customizing Queries/index.html">Customizing Queries</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/NamedQuery/index.html">NamedQuery</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/ObjectIdQuery/index.html">ObjectIdQuery</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Parameterized Queries/index.html">Parameterized Queries</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Qualifier Expressions/index.html">Qualifier Expressions</a><ul>
+</ul>
+</li>
+<li><a href="../../../../Documentation/User Guide/Queries/Queries Stored in DataMap/index.html">Queries Stored in DataMap</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/QueryChain/index.html">QueryChain</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/RelationshipQuery/index.html">RelationshipQuery</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/SQLTemplate Query/index.html">SQLTemplate Query</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Scripting SQLTemplate/index.html">Scripting SQLTemplate</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/SelectQuery/index.html">SelectQuery</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/SelectQuery Customization/index.html">SelectQuery Customization</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Using Orderings/index.html">Using Orderings</a></li>
+</ul>
+</li>
+<li><a href="../../../../Documentation/User Guide/DataObjects/index.html">DataObjects</a></li>
+<li><a href="../../../../Documentation/User Guide/Stored Procedures/index.html">Stored Procedures</a></li>
+<li><a href="../../../../Documentation/User Guide/Expressions/index.html">Expressions</a></li>
+<li><a href="../../../../Documentation/User Guide/Performance Tuning/index.html">Performance Tuning</a></li>
+<li><a href="../../../../Documentation/User Guide/Deployment/index.html">Deployment</a></li>
+<li><a href="../../../../Documentation/User Guide/Ant Tasks/index.html">Ant Tasks</a></li>
+<li><a href="../../../../Documentation/User Guide/Access Stack Internals/index.html">Access Stack Internals</a></li>
+<li><a href="../../../../Documentation/User Guide/DataViews/index.html">DataViews</a></li>
+</ul>
+</div>
+<div id="ConfluenceContent"><table cellpadding='5' width='85%' cellspacing='8px' class='noteMacro' border="0" align='center'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="../../../../images/emoticons/warning.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>This chapter is dedicated to the use of expressions as qualifiers. A detailed discussion on expressions in general is provided at <a href="../../../../Documentation/User Guide/Expressions/index.html" title="Expressions">Expressions</a>.</td></tr></table>
+
+<p>The previous chapter showed how to build a query to fetch all data from a single table. In most situations though only a subset of data matching a certain criteria is needed. Cayenne provides an expressions package to control the filtering behavior of the queries. Expressions applied to queries are called "qualifiers".</p>
+
+<p>SelectQuery provides a few ways to initialize and modify the qualifier:</p>
+
+<ul>
+	<li>public <b>SelectQuery</b>(Class objectClass, Expression e)<br/>
+      Passing expression as a second argument in constructor.</li>
+	<li>public void <b>setQualifier</b>(Expression qualifier)<br/>
+      Explicitly setting the qualifier expression.</li>
+	<li>public void <b>andQualifier</b>(Expression e)<br/>
+      Adding an expression to an already existing qualifier using logical AND.</li>
+	<li>public void <b>orQualifier</b>(Expression e)<br/>
+      Adding an expression to an already existing qualifier using logical OR.</li>
+</ul>
+</div>
+</div>
+  <div class="clearer">.</div>
+  <div style="height: 12px; background-image: url('../../../../images/border_bottom.gif'); background-repeat: repeat-x;"></div>
+
+  <div class="smalltext copyright">
+    Copyright &copy;2001-2006 ObjectStyle Group and content authors
+  </div>
+
+</body>
+</html>

Propchange: incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User Guide/Queries/Qualifier Expressions/index.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User Guide/Queries/Queries Stored in DataMap/index.html
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User%20Guide/Queries/Queries%20Stored%20in%20DataMap/index.html?rev=405581&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User Guide/Queries/Queries Stored in DataMap/index.html (added)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User Guide/Queries/Queries Stored in DataMap/index.html Tue May  9 18:10:42 2006
@@ -0,0 +1,84 @@
+<html>
+  <head>
+    <title>Cayenne Documentation - Queries Stored in DataMap</title>
+    <style type="text/css">@import "../../../../style.css";</style>
+  </head>
+<body>
+  <div class="header">
+    <div style="float: left;"><a href="http://objectstyle.org/cayenne/"><img src="../../../../images/logo.gif" align="absmiddle" border="0"></a></div>
+    <span class="logoSpaceLink"><a href="../../../../index.html">Cayenne User Documentation</a></span><br />
+    <span class="pagetitle">Queries Stored in DataMap</span>
+  </div>
+<div id="cayenne_toc">
+<ul>
+<li><a href="../../../../Documentation/User Guide/Introduction/index.html">Introduction</a></li>
+<li><a href="../../../../Documentation/User Guide/Installation/index.html">Installation</a></li>
+<li><a href="../../../../Documentation/User Guide/Quick Start/index.html">Quick Start</a></li>
+<li><a href="../../../../Documentation/User Guide/Design/index.html">Design</a></li>
+<li><a href="../../../../Documentation/User Guide/Generating Classes/index.html">Generating Classes</a></li>
+<li><a href="../../../../Documentation/User Guide/DataContext/index.html">DataContext</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/index.html">Queries</a><ul>
+<li><a href="../../../../Documentation/User Guide/Queries/Caching Query Results/index.html">Caching Query Results</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Customizing Queries/index.html">Customizing Queries</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/NamedQuery/index.html">NamedQuery</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/ObjectIdQuery/index.html">ObjectIdQuery</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Parameterized Queries/index.html">Parameterized Queries</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Qualifier Expressions/index.html">Qualifier Expressions</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Queries Stored in DataMap/index.html">Queries Stored in DataMap</a><ul>
+</ul>
+</li>
+<li><a href="../../../../Documentation/User Guide/Queries/QueryChain/index.html">QueryChain</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/RelationshipQuery/index.html">RelationshipQuery</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/SQLTemplate Query/index.html">SQLTemplate Query</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Scripting SQLTemplate/index.html">Scripting SQLTemplate</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/SelectQuery/index.html">SelectQuery</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/SelectQuery Customization/index.html">SelectQuery Customization</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Using Orderings/index.html">Using Orderings</a></li>
+</ul>
+</li>
+<li><a href="../../../../Documentation/User Guide/DataObjects/index.html">DataObjects</a></li>
+<li><a href="../../../../Documentation/User Guide/Stored Procedures/index.html">Stored Procedures</a></li>
+<li><a href="../../../../Documentation/User Guide/Expressions/index.html">Expressions</a></li>
+<li><a href="../../../../Documentation/User Guide/Performance Tuning/index.html">Performance Tuning</a></li>
+<li><a href="../../../../Documentation/User Guide/Deployment/index.html">Deployment</a></li>
+<li><a href="../../../../Documentation/User Guide/Ant Tasks/index.html">Ant Tasks</a></li>
+<li><a href="../../../../Documentation/User Guide/Access Stack Internals/index.html">Access Stack Internals</a></li>
+<li><a href="../../../../Documentation/User Guide/DataViews/index.html">DataViews</a></li>
+</ul>
+</div>
+<div id="ConfluenceContent"><p>To facilitate reuse of queries users can assign symbolic names to them and store such named queries in a DataMap. Normally this is done by <a href="../../../../Documentation/Modeler Guide/Modeling Queries/index.html" title="Modeling Queries">creating a query in CayenneModeler</a>. Storing queries in a DataMap reduces the amount of code and speeds up query creation process.</p>
+
+<p>This example shows how to get a shared instance of a stored query, and use it as a template for customized query.</p>
+<div class="code"><div class="codeContent">
+<pre class="code-java">DataContext context = ... <span class="code-comment">// assume <span class="code-keyword">this</span> exists
+</span>
+<span class="code-comment">// 1. lookup prototype
+</span>
+<span class="code-comment">// note a <span class="code-keyword">cast</span> to SelectQuery... Generally DataMap can store any type of queries
+</span>SelectQuery prototype = (SelectQuery) context.getEntityResolver().lookupQuery(<span class="code-quote">"MySelect"</span>);
+
+<span class="code-comment">// 2. customize query
+</span>Map params = <span class="code-keyword">new</span> HashMap();
+params.put(<span class="code-quote">"aname"</span>, <span class="code-quote">"Monet"</span>);
+SelectQuery query = prototype.queryWithParameters(params);
+
+<span class="code-comment">// 3. execute query
+</span>List objects = context.performQuery(query);</pre>
+</div></div>
+<p>DataContext supports running a named query with preset parameters directly:</p>
+<div class="code"><div class="codeContent">
+<pre class="code-java">DataContext context = ... <span class="code-comment">// assume <span class="code-keyword">this</span> exists
+</span>
+<span class="code-comment">// <span class="code-quote">"<span class="code-keyword">false</span>"</span> indicates that a cached result should be used <span class="code-keyword">if</span> available 
+</span>List objects = context.performQuery(<span class="code-quote">"MySelect"</span>, <span class="code-keyword">false</span>);</pre>
+</div></div></div>
+</div>
+  <div class="clearer">.</div>
+  <div style="height: 12px; background-image: url('../../../../images/border_bottom.gif'); background-repeat: repeat-x;"></div>
+
+  <div class="smalltext copyright">
+    Copyright &copy;2001-2006 ObjectStyle Group and content authors
+  </div>
+
+</body>
+</html>

Propchange: incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User Guide/Queries/Queries Stored in DataMap/index.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User Guide/Queries/QueryChain/index.html
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User%20Guide/Queries/QueryChain/index.html?rev=405581&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User Guide/Queries/QueryChain/index.html (added)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User Guide/Queries/QueryChain/index.html Tue May  9 18:10:42 2006
@@ -0,0 +1,69 @@
+<html>
+  <head>
+    <title>Cayenne Documentation - QueryChain</title>
+    <style type="text/css">@import "../../../../style.css";</style>
+  </head>
+<body>
+  <div class="header">
+    <div style="float: left;"><a href="http://objectstyle.org/cayenne/"><img src="../../../../images/logo.gif" align="absmiddle" border="0"></a></div>
+    <span class="logoSpaceLink"><a href="../../../../index.html">Cayenne User Documentation</a></span><br />
+    <span class="pagetitle">QueryChain</span>
+  </div>
+<div id="cayenne_toc">
+<ul>
+<li><a href="../../../../Documentation/User Guide/Introduction/index.html">Introduction</a></li>
+<li><a href="../../../../Documentation/User Guide/Installation/index.html">Installation</a></li>
+<li><a href="../../../../Documentation/User Guide/Quick Start/index.html">Quick Start</a></li>
+<li><a href="../../../../Documentation/User Guide/Design/index.html">Design</a></li>
+<li><a href="../../../../Documentation/User Guide/Generating Classes/index.html">Generating Classes</a></li>
+<li><a href="../../../../Documentation/User Guide/DataContext/index.html">DataContext</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/index.html">Queries</a><ul>
+<li><a href="../../../../Documentation/User Guide/Queries/Caching Query Results/index.html">Caching Query Results</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Customizing Queries/index.html">Customizing Queries</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/NamedQuery/index.html">NamedQuery</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/ObjectIdQuery/index.html">ObjectIdQuery</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Parameterized Queries/index.html">Parameterized Queries</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Qualifier Expressions/index.html">Qualifier Expressions</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Queries Stored in DataMap/index.html">Queries Stored in DataMap</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/QueryChain/index.html">QueryChain</a><ul>
+</ul>
+</li>
+<li><a href="../../../../Documentation/User Guide/Queries/RelationshipQuery/index.html">RelationshipQuery</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/SQLTemplate Query/index.html">SQLTemplate Query</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Scripting SQLTemplate/index.html">Scripting SQLTemplate</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/SelectQuery/index.html">SelectQuery</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/SelectQuery Customization/index.html">SelectQuery Customization</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Using Orderings/index.html">Using Orderings</a></li>
+</ul>
+</li>
+<li><a href="../../../../Documentation/User Guide/DataObjects/index.html">DataObjects</a></li>
+<li><a href="../../../../Documentation/User Guide/Stored Procedures/index.html">Stored Procedures</a></li>
+<li><a href="../../../../Documentation/User Guide/Expressions/index.html">Expressions</a></li>
+<li><a href="../../../../Documentation/User Guide/Performance Tuning/index.html">Performance Tuning</a></li>
+<li><a href="../../../../Documentation/User Guide/Deployment/index.html">Deployment</a></li>
+<li><a href="../../../../Documentation/User Guide/Ant Tasks/index.html">Ant Tasks</a></li>
+<li><a href="../../../../Documentation/User Guide/Access Stack Internals/index.html">Access Stack Internals</a></li>
+<li><a href="../../../../Documentation/User Guide/DataViews/index.html">DataViews</a></li>
+</ul>
+</div>
+<div id="ConfluenceContent"><p><tt>QueryChain</tt>, as the name implies, is a Query that is itself a collection of other queries. It simplifies an execution of multiple queries in a single batch. E.g.:</p>
+
+<div class="code"><div class="codeContent">
+<pre class="code-java">QueryChain query = <span class="code-keyword">new</span> QueryChain();
+query.addQuery(<span class="code-keyword">new</span> SQLTemplate(Project.class, <span class="code-quote">"delete from project"</span>, <span class="code-keyword">false</span>));
+query.addQuery(<span class="code-keyword">new</span> SQLTemplate(Project.class, <span class="code-quote">"delete from person"</span>, <span class="code-keyword">false</span>));
+query.addQuery(<span class="code-keyword">new</span> SQLTemplate(Project.class, <span class="code-quote">"delete from department"</span>, <span class="code-keyword">false</span>));
+
+DataContext context = ...
+context.performNonSelectingQuery(query);</pre>
+</div></div></div>
+</div>
+  <div class="clearer">.</div>
+  <div style="height: 12px; background-image: url('../../../../images/border_bottom.gif'); background-repeat: repeat-x;"></div>
+
+  <div class="smalltext copyright">
+    Copyright &copy;2001-2006 ObjectStyle Group and content authors
+  </div>
+
+</body>
+</html>

Propchange: incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User Guide/Queries/QueryChain/index.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User Guide/Queries/RelationshipQuery/index.html
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User%20Guide/Queries/RelationshipQuery/index.html?rev=405581&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User Guide/Queries/RelationshipQuery/index.html (added)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User Guide/Queries/RelationshipQuery/index.html Tue May  9 18:10:42 2006
@@ -0,0 +1,65 @@
+<html>
+  <head>
+    <title>Cayenne Documentation - RelationshipQuery</title>
+    <style type="text/css">@import "../../../../style.css";</style>
+  </head>
+<body>
+  <div class="header">
+    <div style="float: left;"><a href="http://objectstyle.org/cayenne/"><img src="../../../../images/logo.gif" align="absmiddle" border="0"></a></div>
+    <span class="logoSpaceLink"><a href="../../../../index.html">Cayenne User Documentation</a></span><br />
+    <span class="pagetitle">RelationshipQuery</span>
+  </div>
+<div id="cayenne_toc">
+<ul>
+<li><a href="../../../../Documentation/User Guide/Introduction/index.html">Introduction</a></li>
+<li><a href="../../../../Documentation/User Guide/Installation/index.html">Installation</a></li>
+<li><a href="../../../../Documentation/User Guide/Quick Start/index.html">Quick Start</a></li>
+<li><a href="../../../../Documentation/User Guide/Design/index.html">Design</a></li>
+<li><a href="../../../../Documentation/User Guide/Generating Classes/index.html">Generating Classes</a></li>
+<li><a href="../../../../Documentation/User Guide/DataContext/index.html">DataContext</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/index.html">Queries</a><ul>
+<li><a href="../../../../Documentation/User Guide/Queries/Caching Query Results/index.html">Caching Query Results</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Customizing Queries/index.html">Customizing Queries</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/NamedQuery/index.html">NamedQuery</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/ObjectIdQuery/index.html">ObjectIdQuery</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Parameterized Queries/index.html">Parameterized Queries</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Qualifier Expressions/index.html">Qualifier Expressions</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Queries Stored in DataMap/index.html">Queries Stored in DataMap</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/QueryChain/index.html">QueryChain</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/RelationshipQuery/index.html">RelationshipQuery</a><ul>
+</ul>
+</li>
+<li><a href="../../../../Documentation/User Guide/Queries/SQLTemplate Query/index.html">SQLTemplate Query</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Scripting SQLTemplate/index.html">Scripting SQLTemplate</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/SelectQuery/index.html">SelectQuery</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/SelectQuery Customization/index.html">SelectQuery Customization</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Using Orderings/index.html">Using Orderings</a></li>
+</ul>
+</li>
+<li><a href="../../../../Documentation/User Guide/DataObjects/index.html">DataObjects</a></li>
+<li><a href="../../../../Documentation/User Guide/Stored Procedures/index.html">Stored Procedures</a></li>
+<li><a href="../../../../Documentation/User Guide/Expressions/index.html">Expressions</a></li>
+<li><a href="../../../../Documentation/User Guide/Performance Tuning/index.html">Performance Tuning</a></li>
+<li><a href="../../../../Documentation/User Guide/Deployment/index.html">Deployment</a></li>
+<li><a href="../../../../Documentation/User Guide/Ant Tasks/index.html">Ant Tasks</a></li>
+<li><a href="../../../../Documentation/User Guide/Access Stack Internals/index.html">Access Stack Internals</a></li>
+<li><a href="../../../../Documentation/User Guide/DataViews/index.html">DataViews</a></li>
+</ul>
+</div>
+<div id="ConfluenceContent"><p><tt>RelationshipQuery</tt> is used by Cayenne internally to fetch object(s) related to a single given object via a mapped ObjRelationship. In some cases the query can be used directly in the application, e.g. if we want to refresh related objects.</p>
+
+<div class="code"><div class="codeContent">
+<pre class="code-java">ObjectId id = <span class="code-keyword">new</span> ObjectId(<span class="code-quote">"Artist"</span>, <span class="code-quote">"ARTIST_ID"</span>, 55);
+RelationshipQuery query = <span class="code-keyword">new</span> RelationshipQuery(id, <span class="code-quote">"paintingArray"</span>, <span class="code-keyword">true</span>);
+List paintings = context.performQuery(query);</pre>
+</div></div></div>
+</div>
+  <div class="clearer">.</div>
+  <div style="height: 12px; background-image: url('../../../../images/border_bottom.gif'); background-repeat: repeat-x;"></div>
+
+  <div class="smalltext copyright">
+    Copyright &copy;2001-2006 ObjectStyle Group and content authors
+  </div>
+
+</body>
+</html>

Propchange: incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User Guide/Queries/RelationshipQuery/index.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User Guide/Queries/SQLTemplate Query/index.html
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User%20Guide/Queries/SQLTemplate%20Query/index.html?rev=405581&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User Guide/Queries/SQLTemplate Query/index.html (added)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User Guide/Queries/SQLTemplate Query/index.html Tue May  9 18:10:42 2006
@@ -0,0 +1,113 @@
+<html>
+  <head>
+    <title>Cayenne Documentation - SQLTemplate Query</title>
+    <style type="text/css">@import "../../../../style.css";</style>
+  </head>
+<body>
+  <div class="header">
+    <div style="float: left;"><a href="http://objectstyle.org/cayenne/"><img src="../../../../images/logo.gif" align="absmiddle" border="0"></a></div>
+    <span class="logoSpaceLink"><a href="../../../../index.html">Cayenne User Documentation</a></span><br />
+    <span class="pagetitle">SQLTemplate Query</span>
+  </div>
+<div id="cayenne_toc">
+<ul>
+<li><a href="../../../../Documentation/User Guide/Introduction/index.html">Introduction</a></li>
+<li><a href="../../../../Documentation/User Guide/Installation/index.html">Installation</a></li>
+<li><a href="../../../../Documentation/User Guide/Quick Start/index.html">Quick Start</a></li>
+<li><a href="../../../../Documentation/User Guide/Design/index.html">Design</a></li>
+<li><a href="../../../../Documentation/User Guide/Generating Classes/index.html">Generating Classes</a></li>
+<li><a href="../../../../Documentation/User Guide/DataContext/index.html">DataContext</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/index.html">Queries</a><ul>
+<li><a href="../../../../Documentation/User Guide/Queries/Caching Query Results/index.html">Caching Query Results</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Customizing Queries/index.html">Customizing Queries</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/NamedQuery/index.html">NamedQuery</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/ObjectIdQuery/index.html">ObjectIdQuery</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Parameterized Queries/index.html">Parameterized Queries</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Qualifier Expressions/index.html">Qualifier Expressions</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Queries Stored in DataMap/index.html">Queries Stored in DataMap</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/QueryChain/index.html">QueryChain</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/RelationshipQuery/index.html">RelationshipQuery</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/SQLTemplate Query/index.html">SQLTemplate Query</a><ul>
+</ul>
+</li>
+<li><a href="../../../../Documentation/User Guide/Queries/Scripting SQLTemplate/index.html">Scripting SQLTemplate</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/SelectQuery/index.html">SelectQuery</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/SelectQuery Customization/index.html">SelectQuery Customization</a></li>
+<li><a href="../../../../Documentation/User Guide/Queries/Using Orderings/index.html">Using Orderings</a></li>
+</ul>
+</li>
+<li><a href="../../../../Documentation/User Guide/DataObjects/index.html">DataObjects</a></li>
+<li><a href="../../../../Documentation/User Guide/Stored Procedures/index.html">Stored Procedures</a></li>
+<li><a href="../../../../Documentation/User Guide/Expressions/index.html">Expressions</a></li>
+<li><a href="../../../../Documentation/User Guide/Performance Tuning/index.html">Performance Tuning</a></li>
+<li><a href="../../../../Documentation/User Guide/Deployment/index.html">Deployment</a></li>
+<li><a href="../../../../Documentation/User Guide/Ant Tasks/index.html">Ant Tasks</a></li>
+<li><a href="../../../../Documentation/User Guide/Access Stack Internals/index.html">Access Stack Internals</a></li>
+<li><a href="../../../../Documentation/User Guide/DataViews/index.html">DataViews</a></li>
+</ul>
+</div>
+<div id="ConfluenceContent"><p>Not all features of SQL can (or should) be mapped in the object model in terms of DataObjects. For such cases Cayenne provides a powerful mechanism for running both selecting and non-selecting SQL using scriptable <span class="nobr"><a href="http://objectstyle.org/cayenne/api/cayenne/org/objectstyle/cayenne/query/SQLTemplate.html" title="Visit page outside Confluence" rel="nofollow">SQLTemplate<sup><img class="rendericon" src="../../../../images/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> query. This chapter describes how simple SQLTemplates can be created and executed with DataContext to select or update the database data. Subsequent chapters show how to build SQL dynamically, bind parameters and describe result sets using SQLTemplate scripting features.</p>
+
+<h3><a name="SQLTemplateQuery-CreatingSQLTemplate"></a>Creating SQLTemplate</h3>
+
+<p>SQLTemplates can be built using CayenneModeler. Here we demonstrate how to do the same thing via API. SQLTemplate consists of root and dynamic template string. Dynamic behavior of the template is discussed in subsequent chapters, for now it is sufficient to know that the template string is simply a valid SQL statement in the target database SQL dialect.</p>
+<div class="code"><div class="codeContent">
+<pre class="code-java"><span class="code-keyword">import</span> org.objectstyle.cayenne.query.SQLTemplate;
+...
+<span class="code-comment">// create selecting SQLTemplate
+</span>SQLTemplate selectQuery = <span class="code-keyword">new</span> SQLTemplate(Artist.class, <span class="code-quote">"select * from ARTIST"</span>);
+...
+<span class="code-comment">// create updating SQLTemplate
+</span>SQLTemplate updateQuery = <span class="code-keyword">new</span> SQLTemplate(Artist.class, <span class="code-quote">"delete from ARTIST"</span>);</pre>
+</div></div>
+
+<h3><a name="SQLTemplateQuery-SelectingObjectswithSQLTemplate"></a>Selecting Objects with SQLTemplate</h3>
+
+<p>Selecting SQLTemplate is very similar to SelectQuery in many respects. It can be executed via <tt>DataContext.performQuery(..)</tt> and supports the same configuration parameters, such as fetch limit, pagination, etc. It can be configured to return DataObjects (default) or data rows.</p>
+<div class="code"><div class="codeContent">
+<pre class="code-java"><span class="code-keyword">import</span> org.objectstyle.cayenne.query.SQLTemplate;
+...
+<span class="code-comment">// fetch all artists, but no more than 1000 objects...
+</span>SQLTemplate rawSelect = <span class="code-keyword">new</span> SQLTemplate(Artist.class, <span class="code-quote">"select * from ARTIST"</span>);
+rawSelect.setFetchLimit(1000);
+
+List artists = dataContext.performQuery(rawSelect);</pre>
+</div></div>
+
+<h3><a name="SQLTemplateQuery-ModifyingDatawithSQLTemplate"></a>Modifying Data with SQLTemplate</h3>
+
+<p>Non-selecting SQLTemplate allows to execute arbitrary SQL that modifies the database, but does not return the results. <tt>DataContext.performNonSelectingQuery(..)</tt> is used for this task.</p>
+<table cellpadding='5' width='85%' cellspacing='8px' class='noteMacro' border="0" align='center'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="../../../../images/emoticons/warning.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>
+<p>Developers making database changes via SQLTemplate must realize that these changes are done directly to the database, bypassing ObjectStore, and therefore may potentially leave object graph in an inconsistent state.</p></td></tr></table>
+<div class="code"><div class="codeContent">
+<pre class="code-java"><span class="code-keyword">import</span> org.objectstyle.cayenne.query.SQLTemplate;
+...
+<span class="code-comment">// fetch all artists, but no more than 1000 objects...
+</span>SQLTemplate rawDelete = <span class="code-keyword">new</span> SQLTemplate(Artist.class, <span class="code-quote">"delete from ARTIST"</span>);
+<span class="code-object">int</span>[] deleteCounts = dataContext.performNonSelectingQuery(rawDelete);</pre>
+</div></div>
+
+<h3><a name="SQLTemplateQuery-CustomizingSQLDialects"></a>Customizing SQL Dialects</h3>
+
+<p>Even though SQL is an industry standard, different DB vendors still have their own dialects and extensions. Two versions of the same query written for Oracle and PostgreSQL may look quiet different.</p>
+
+<p>Each SQLTemplate query has a default template, usually set in constructor. Internally it also keeps a map of alternative templates. This map normally uses a fully-qualified class name of the target DbAdapter as a key. This way Cayenne can determine which one of the SQL strings to use during the execution. Alternative SQL strings are configured using <tt>SQLTemplate.setTemplate(...)</tt>:</p>
+<div class="code"><div class="codeContent">
+<pre class="code-java"><span class="code-comment">// build template with <span class="code-keyword">default</span> SQL
+</span>SQLTemplate query = <span class="code-keyword">new</span> SQLTemplate(Artist.class, <span class="code-quote">"select * from ARTIST"</span>);
+
+<span class="code-comment">// <span class="code-keyword">for</span> Postgres it would be nice to trim the CHAR ARTIST_NAME column
+</span><span class="code-comment">// or otherwise it will be returned padded with spaces
+</span><span class="code-object">String</span> pgTemplate = <span class="code-quote">"SELECT ARTIST_ID, RTRIM(ARTIST_NAME), DATE_OF_BIRTH FROM ARTIST"</span>;
+query.setTemplate(PostgresAdapter.class.getName(), pgTemplate);</pre>
+</div></div></div>
+</div>
+  <div class="clearer">.</div>
+  <div style="height: 12px; background-image: url('../../../../images/border_bottom.gif'); background-repeat: repeat-x;"></div>
+
+  <div class="smalltext copyright">
+    Copyright &copy;2001-2006 ObjectStyle Group and content authors
+  </div>
+
+</body>
+</html>

Propchange: incubator/cayenne/main/trunk/cayenne/cayenne-other/wiki-docs/Documentation/User Guide/Queries/SQLTemplate Query/index.html
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message