Cayenne Guide


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

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
3. CayenneModeler Application
Working with Mapping Projects
Reverse Engineering Database
Generating Database Schema
Generating Java Classes
Modeling Inheritance
Modeling Generic Persistent Classes
Mapping ObjAttributes to Custom Classes
Modeling Primary Key Generation Strategy
II. Cayenne Framework
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
Persistent Object and its Lifecycle
ObjectContext Persistence API
Cayenne Helper Class
ObjectContext Nesting
Generic Persistent Objects
7. Expressions
Expressions Overview
Path Expressions
Creating Expressions from Strings
Creating Expressions with API
Evaluating Expressions in Memory
8. Orderings
9. Queries
Custom Queries
10. Lifecycle Events
Types of Lifecycle Events
Callbacks on Persistent Objects
Callbacks on Non-Persistent Listeners
Combining Listeners with DataChannelFilters
11. Performance Tuning
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
18. Current Limitations
A. Configuration Properties
B. Service Collections
C. Expressions BNF

List of Tables

4.1. cgen required parameters
4.2. cgen optional parameters
4.3. cdbgen required parameters
4.4. cdbgen optional parameters
4.5. cdbimport required parameters
4.6. cdbimport optional parameters
6.1. Persistence States
10.1. Lifecycle Event Types
A.1. Configuration Properties Recognized by ServerRuntime and/or ClientRuntime
B.1. Service Collection Keys Present in ServerRuntime and/or ClientRuntime