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
DataNode
DbEntity
ObjEntity
Embeddable
Procedure
Query
3. CayenneModeler Application
Working with Mapping Projects
Reverse Engineering Database
Generating Database Schema
Migrations
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
Dependencies
Maven Projects
Gradle 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 via API
Evaluating Expressions in Memory
Translating Expressions to EJBQL
8. Orderings
9. Queries
ObjectSelect
EJBQLQuery
SelectById
SQLSelect and SQLExec
MappedSelect and MappedExec
ProcedureCall
Custom Queries
SQLTemplate
10. Lifecycle Events
Types of Lifecycle Events
Callbacks on Persistent Objects
Callbacks on Non-Persistent Listeners
Combining Listeners with DataChannelFilters
11. Performance Tuning
Prefetching
Data Rows
Specific Attributes and Relationships with EJBQL
Iterated Queries
Paginated Queries
Caching and Fresh Data
Turning off Synchronization of ObjectContexts
12. Customizing Cayenne Runtime
Dependency Injection Container
Customization Strategies
Using custom data types
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
IV. DB-First Flow
19. Introduction
"DB-first" Flow
Introduction to "cdbimport"
20. Filtering
Process everything from schema/catalog
Combine Schema and Catalog filters
Including and Excluding tables, columns and procedures
Complete filtering example
Ant configuration example
21. Other Settings
Skip Relationships Loading
Skip Primary Keys Loading
Table Types
22. Reverse Engineering in Cayenne Modeler
DataSource selection
Reverse engineering options
V. Cayenne Additional Modules
23. Cache invalidation extension
Description
Including in a project
Usage
24. Commit log extension
Description
Including in a project
Usage
25. Crypto extension
Description
Including in a project
Usage
26. Apache Commons DBCP integration
Description
Including in a project
Usage
27. Java 8 extension
Description
Including in a project
Usage
28. JCache integration
Description
Including in a project
Usage
29. Joda time extension
Description
Including in a project
Usage
A. Configuration Properties
B. Service Collections
C. Expressions BNF

List of Tables

1.1. Cayenne Version History
1.2. modeler plugin parameters
4.1. cgen required parameters
4.2. cgen optional parameters
4.3. cdbgen required parameters
4.4. <dataSource> parameters
4.5. cdbgen optional parameters
4.6. cdbimport parameters
4.7. <dataSource> parameters
4.8. <dbimport> 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