Return-Path: X-Original-To: apmail-cayenne-commits-archive@www.apache.org Delivered-To: apmail-cayenne-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 37237D3B7 for ; Wed, 26 Dec 2012 19:21:04 +0000 (UTC) Received: (qmail 38848 invoked by uid 500); 26 Dec 2012 19:21:04 -0000 Delivered-To: apmail-cayenne-commits-archive@cayenne.apache.org Received: (qmail 38818 invoked by uid 500); 26 Dec 2012 19:21:04 -0000 Mailing-List: contact commits-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cayenne.apache.org Delivered-To: mailing list commits@cayenne.apache.org Received: (qmail 38811 invoked by uid 99); 26 Dec 2012 19:21:04 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Dec 2012 19:21:04 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Dec 2012 19:21:01 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 347122388ABA for ; Wed, 26 Dec 2012 19:20:37 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r843922 [3/5] - in /websites/staging/cayenne/trunk/content: ./ docs/3.1/cayenne-guide/ docs/3.1/cayenne-guide/css/ docs/3.1/tutorial/ docs/3.1/tutorial/css/ Date: Wed, 26 Dec 2012 19:20:35 -0000 To: commits@cayenne.apache.org From: buildbot@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121226192037.347122388ABA@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: websites/staging/cayenne/trunk/content/docs/3.1/cayenne-guide/index.html ============================================================================== --- websites/staging/cayenne/trunk/content/docs/3.1/cayenne-guide/index.html (original) +++ websites/staging/cayenne/trunk/content/docs/3.1/cayenne-guide/index.html Wed Dec 26 19:20:35 2012 @@ -1,11 +1,11 @@ Cayenne Guide

Cayenne Guide

License

Licensed to the Apache Software Foundation (ASF) under one or more contributor - license agreements. See the NOTICE file distributed with this work for additional - information regarding copyright ownership. The ASF licenses this file to you under - the Apache License, Version 2.0 (the "License"); you may not use this file except in - compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed - under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR - CONDITIONS OF ANY KIND, either express or implied. See the License for the specific - language governing permissions and limitations under the License.


Table of Contents

I. Object Relational Mapping with Cayenne
1. Setup
System Requirements
Running CayenneModeler
2. Cayenne Mapping Structure
Cayenne Project
DataMap
DataNod e
DbEntity
ObjEntity
Embeddable
Procedure
Query
Listeners and Callbacks
3. CayenneModeler Application
Working with Mapping Projects
Reverse Engineering Database
Generating Database Schema
Migrations
Generating Java Classes
Modeling Inheritance
Modeling Generic Persistent Classes
Modeling Primary Key Generation Strategy
II. Cayenne Framework< /span>
4. Including Cayenne in a Project
Jar Files and Dependencies
Maven Projects
Ant Projects
5. Starting Cayenne
Starting and Stopping ServerRuntime
Merging Multiple Projects
Web Applications
6. Persistent Objects and ObjectContext
ObjectContext
Persistent Object and its Lifecycle
ObjectContext Persistence API
Cayenne Helper Class
ObjectContext Nesting
Generic Persistent Objects
Transactions
7. Expressions
Expressions Overview
Path Expressions
Creating Expressions from Strings
Creating Expressions with API
Evaluating Expressions in Memory
8. Orderings
9. Queries
Selec tQuery
EJBQLQuery
SQLTemplateQuery
ProcedureQuery
NamedQuery
Custom Queries
10. Lifecycle Events
Types of Lifecycle Events
Lifecycle Callbacks and Listeners
11. Performance Tuning
Prefetching
Data Rows
Iterated Queries
Paginated Queries
Caching and Fresh Data
Turning off Synchronization of ObjectContexts
12. Customizing Cayenne Runtime
Dependency Injection Container
Customization Strategies
Noteworthy Built-in Services
III. Cayenne Framework - Remote Object Persistence
13. Introduction to ROP
What is ROP
Main Features
14. ROP Setup
System Requirements
Jar Files and Dependencies
15. Implementing ROP Server
16. Implementing ROP Client
17. ROP Deployment
Deploying ROP Server
Deploying ROP Client
Security
18. Current Limitations
A. Configuration Properties
B. Service Collections
C. Expressions BNF
\ No newline at end of file + license agreements. See the NOTICE file distributed with this work for additional + information regarding copyright ownership. The ASF licenses this file to you under + the Apache License, Version 2.0 (the "License"); you may not use this file except in + compliance with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed + under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + CONDITIONS OF ANY KIND, either express or implied. See the License for the specific + language governing permissions and limitations under the License.


Table of Contents

I. Object Relational Mapping with Cayenne
1. Setup
System Requirements
Running CayenneModeler
2. Cayenne Mapping Structure
Cayenne Project
DataMap
DataNode
DbEntity
ObjEntity
Embeddable
Procedure
Query
Listeners and Callbacks
3. CayenneModeler Application
Working with Mapping Projects
Reverse Engineering Database
Generating Database Schema
Migrations
Generating Java Classes
Modeling Inheritance
Modeling Generic Persistent Classes
Modeling Primary Key Generation Strategy
II. Cayenne Fr amework
4. Including Cayenne in a Project
Jar Files and Dependencies
Maven Projects
Ant Projects
5. Starting Cayenne
Starting and Stopping ServerRuntime
Merging Multiple Projects
Web Applications
6. Persistent Objects and ObjectContext
ObjectContext
Persistent Object and its Lifecycle
ObjectContext Persistence API
Cayenne Helper Class
ObjectContext Nesting
Generic Persistent Objects
Transactions
7. Expressions
Expressions Overview
Path Expressions
Creating Expressions from Strings
Creating Expressions with API
Evaluating Expressions in Memory
8. Orderings
9. Queries
SelectQuery
EJBQLQuery
SQLTemplateQuery
ProcedureQuery
NamedQuery
Custom Queries
10. Lifecycle Events
Types of Lifecycle Events
Lifecycle Callbacks and Listeners
11. Performance Tuning
Prefetching
Data Rows
Iterated Queries
Paginated Queries
Caching and Fresh Data
Turning off Synchronization of ObjectContexts
12. Customizing Cayenne Runtime
Dependency Injection Container
Customization Strategies
Noteworthy Built-in Services
III. Cayenne Framework - Remote Object Persistence
13. Introduction to ROP
What is ROP
Main Features
14. ROP Setup
System Requirements
Jar Files and Dependencies
15. Implementing ROP Server
16. Implementing ROP Client
17. ROP Deployment
Deploying ROP Server
Deploying ROP Client
Security
18. Current Limitations
A. Configuration Properties
B. Service Collections
C. Expressions BNF
\ No newline at end of file Modified: websites/staging/cayenne/trunk/content/docs/3.1/cayenne-guide/orderings.html ============================================================================== --- websites/staging/cayenne/trunk/content/docs/3.1/cayenne-guide/orderings.html (original) +++ websites/staging/cayenne/trunk/content/docs/3.1/cayenne-guide/orderings.html Wed Dec 26 19:20:35 2012 @@ -1,12 +1,12 @@ Chapter 8. Orderings

Chapter 8. Orderings

An Ordering object defines how a list of objects should be ordered. Orderings are - essentially path expressions combined with a sorting strategy. Creating an Ordering: -

Ordering o = new Ordering(Painting.NAME_PROPERTY, SortOrder.ASENDING);

Like expressions, orderings are translated into SQL as parts of queries (and the sorting - occurs in the database). Also like expressions, orderings can be used in memory, naturally - - to sort - objects:

Ordering o = new Ordering(Painting.NAME_PROPERTY, SortOrder.ASCENDING_INSENSITIVE);
+            essentially path expressions combined with a sorting strategy. Creating an Ordering:
+            

Ordering o = new Ordering(Painting.NAME_PROPERTY, SortOrder.ASENDING);

Like expressions, orderings are translated into SQL as parts of queries (and the sorting + occurs in the database). Also like expressions, orderings can be used in memory, naturally - + to sort + objects:

Ordering o = new Ordering(Painting.NAME_PROPERTY, SortOrder.ASCENDING_INSENSITIVE);
 List<Painting> list = ...
 o.orderList(list);

Note - that unlike filtering with Expressions, ordering is performed in-place. This list object is - reordered and no new list is created.

\ No newline at end of file + that unlike filtering with Expressions, ordering is performed in-place. This list object is + reordered and no new list is created.

\ No newline at end of file Modified: websites/staging/cayenne/trunk/content/docs/3.1/cayenne-guide/performance-tuning.html ============================================================================== --- websites/staging/cayenne/trunk/content/docs/3.1/cayenne-guide/performance-tuning.html (original) +++ websites/staging/cayenne/trunk/content/docs/3.1/cayenne-guide/performance-tuning.html Wed Dec 26 19:20:35 2012 @@ -1,65 +1,65 @@ Chapter 11. Performance Tuning

Chapter 11. Performance Tuning

Prefetching

Prefetching is a technique that allows to bring back in one query not only the queried - objects, but also objects related to them. In other words it is a controlled eager - relationship resolving mechanism. Prefetching is discussed in the "Performance Tuning" - chapter, as it is a powerful performance optimization method. Another common application - of prefetching is for refreshing stale object relationships.

Prefetching example: -

SelectQuery query = new SelectQuery(Artist.class);
+            objects, but also objects related to them. In other words it is a controlled eager
+            relationship resolving mechanism. Prefetching is discussed in the "Performance Tuning"
+            chapter, as it is a powerful performance optimization method. Another common application
+            of prefetching is for refreshing stale object relationships.

Prefetching example: +

SelectQuery query = new SelectQuery(Artist.class);
 
-// this instructs Cayenne to prefetch one of Artist's relationships
-query.addPrefetch("paintings");
+// this instructs Cayenne to prefetch one of Artist's relationships
+query.addPrefetch("paintings");
 
-// query is expecuted as usual, but the resulting Artists will have
-// their paintings "inflated"
+// query is expecuted as usual, but the resulting Artists will have
+// their paintings "inflated"
 List<Artist> artists = context.performQuery(query);

- All types of relationships can be preftetched - to-one, to-many, flattened.

A prefetch can span multiple relationships: -

 query.addPrefetch("paintings.gallery");

A query can have multiple - prefetches:

query.addPrefetch("paintings"); 
-query.addPrefetch("paintings.gallery"); 

If a query is fetching DataRows, all "disjoint" prefetches are ignored, only "joint" - prefetches are executed (see prefetching semantics discussion below for what disjoint and - joint prefetches mean).

Prefetching Semantics

Prefetching semantics defines a strategy to prefetch relationships. Depending on - it, Cayenne would generate different types of queries. The end result is the same - - query root objects with related objects fully resolved. However semantics can affect - preformance, in some cases significantly. There are 3 types of prefetch semantics, - all defined as constants in - org.apache.cayenne.query.PrefetchTreeNode:

PrefetchTreeNode.JOINT_PREFETCH_SEMANTICS
+            All types of relationships can be preftetched - to-one, to-many, flattened. 

A prefetch can span multiple relationships: +

 query.addPrefetch("paintings.gallery");

A query can have multiple + prefetches:

query.addPrefetch("paintings");
+query.addPrefetch("paintings.gallery"); 

If a query is fetching DataRows, all "disjoint" prefetches are ignored, only "joint" + prefetches are executed (see prefetching semantics discussion below for what disjoint and + joint prefetches mean).

Prefetching Semantics

Prefetching semantics defines a strategy to prefetch relationships. Depending on + it, Cayenne would generate different types of queries. The end result is the same - + query root objects with related objects fully resolved. However semantics can affect + preformance, in some cases significantly. There are 3 types of prefetch semantics, + all defined as constants in + org.apache.cayenne.query.PrefetchTreeNode:

PrefetchTreeNode.JOINT_PREFETCH_SEMANTICS
 PrefetchTreeNode.DISJOINT_PREFETCH_SEMANTICS
 PrefetchTreeNode.DISJOINT_BY_ID_PREFETCH_SEMANTICS

Each query has a default prefetch semantics, so generally users do not have to - worry about changing it, except when performance is a concern, or a few special - cases when a default sematics can't produce the correct result. SelectQuery uses - DISJOINT_PREFETCH_SEMANTICS by default. Semantics can be changed as - follows:

SelectQuery query = new SelectQuery(Artist.class); 
-query.addPrefetch("paintings").setSemantics(
+                worry about changing it, except when performance is a concern, or a few special
+                cases when a default sematics can't produce the correct result. SelectQuery uses
+                DISJOINT_PREFETCH_SEMANTICS by default. Semantics can be changed as
+                follows:

SelectQuery query = new SelectQuery(Artist.class);
+query.addPrefetch("paintings").setSemantics(
                 PrefetchTreeNode.JOINT_PREFETCH_SEMANTICS); 

There's no limitation on mixing different types of semantics in the same - SelectQuery. Multiple prefetches each can have its own semantics.

SQLTemplate and ProcedureQuery are both using JOINT_PREFETCH_SEMANTICS and it can - not be changed due to the nature of these two queries.

Disjoint Prefetching Semantics

This semantics (only applicable to SelectQuery) results in Cayenne generatiing one - SQL statement for the main objects, and a separate statement for each prefetch path - (hence "disjoint" - related objects are not fetched with the main query). Each - additional SQL statement uses a qualifier of the main query plus a set of joins - traversing the preftech path between the main and related entity.

This strategy has an advantage of efficient JVM memory use, and faster overall - result processing by Cayenne, but it requires (1+N) SQL statements to be executed, - where N is the number of prefetched relationships.

Disjoint-by-ID Prefetching Semantics

This is a variation of disjoint prefetch where related objects are matched against - a set of IDs derived from the fetched main objects (or intermediate objects in a - multi-step prefetch). Cayenne limits the size of the generated WHERE clause, as most - DBs can't parse arbitrary large SQL. So prefetch queries are broken into smaller - queries. The size of is controlled by the DI property - Constants.SERVER_MAX_ID_QUALIFIER_SIZE_PROPERTY (the default number of conditions in - the generated WHERE clause is 10000). Cayenne will generate (1 + N * M) SQL - statements for each query using disjoint-by-ID prefetches, where N is the number of - relationships to prefetch, and M is the number of queries for a given prefetch that - is dependent on the number of objects in the result (ideally M = 1).

The advantage of this type of prefetch is that matching database rows by ID may be - much faster than matching the qualifier of the original query. Moreover this is - the only type of prefetch that can handle - SelectQueries with fetch limit. Both joint and - regular disjoint prefetches may produce invalid results or generate inefficient - fetch-the-entire table SQL when fetch limit is in effect.

The disadvantage is that query SQL can get unwieldy for large result sets, as each - object will have to have its own condition in the WHERE clause of the generated - SQL.

Joint Prefetching Semantics

Joint senantics results in a single SQL statement for root objects and any number - of jointly prefetched paths. Cayenne processes in memory a cartesian product of the - entities involved, converting it to an object tree. It uses OUTER joins to connect - prefetched entities.

Joint is the most efficient prefetch type of the three as far as generated SQL - goes. There's always just 1 SQL query generated. Its downsides are the potentially - increased amount of data that needs to get across the network between the - application server and the database, and more data processing that needs to be done - on the Cayenne side.

Data Rows

Iterated Queries

Paginated Queries

Caching and Fresh Data

Object Caching

Query Result Caching

Turning off Synchronization of ObjectContexts

\ No newline at end of file + SelectQuery. Multiple prefetches each can have its own semantics.

SQLTemplate and ProcedureQuery are both using JOINT_PREFETCH_SEMANTICS and it can + not be changed due to the nature of these two queries.

Disjoint Prefetching Semantics

This semantics (only applicable to SelectQuery) results in Cayenne generatiing one + SQL statement for the main objects, and a separate statement for each prefetch path + (hence "disjoint" - related objects are not fetched with the main query). Each + additional SQL statement uses a qualifier of the main query plus a set of joins + traversing the preftech path between the main and related entity.

This strategy has an advantage of efficient JVM memory use, and faster overall + result processing by Cayenne, but it requires (1+N) SQL statements to be executed, + where N is the number of prefetched relationships.

Disjoint-by-ID Prefetching Semantics

This is a variation of disjoint prefetch where related objects are matched against + a set of IDs derived from the fetched main objects (or intermediate objects in a + multi-step prefetch). Cayenne limits the size of the generated WHERE clause, as most + DBs can't parse arbitrary large SQL. So prefetch queries are broken into smaller + queries. The size of is controlled by the DI property + Constants.SERVER_MAX_ID_QUALIFIER_SIZE_PROPERTY (the default number of conditions in + the generated WHERE clause is 10000). Cayenne will generate (1 + N * M) SQL + statements for each query using disjoint-by-ID prefetches, where N is the number of + relationships to prefetch, and M is the number of queries for a given prefetch that + is dependent on the number of objects in the result (ideally M = 1).

The advantage of this type of prefetch is that matching database rows by ID may be + much faster than matching the qualifier of the original query. Moreover this is + the only type of prefetch that can handle + SelectQueries with fetch limit. Both joint and + regular disjoint prefetches may produce invalid results or generate inefficient + fetch-the-entire table SQL when fetch limit is in effect.

The disadvantage is that query SQL can get unwieldy for large result sets, as each + object will have to have its own condition in the WHERE clause of the generated + SQL.

Joint Prefetching Semantics

Joint senantics results in a single SQL statement for root objects and any number + of jointly prefetched paths. Cayenne processes in memory a cartesian product of the + entities involved, converting it to an object tree. It uses OUTER joins to connect + prefetched entities.

Joint is the most efficient prefetch type of the three as far as generated SQL + goes. There's always just 1 SQL query generated. Its downsides are the potentially + increased amount of data that needs to get across the network between the + application server and the database, and more data processing that needs to be done + on the Cayenne side.

Data Rows

Iterated Queries

Paginated Queries

Caching and Fresh Data

Object Caching

Query Result Caching

Turning off Synchronization of ObjectContexts

\ No newline at end of file