CBE Examples on GitHub

Cayenne by Example

Illustrating some of the major features of the Apache Cayenne ORM framework using simple examples.

Download this project as a .zip file Download this project as a tar.gz file

Introduction

Apache Cayenne

Apache Cayenne (or simply Cayenne, for short) is an Object-Relational Mapping (ORM) framework for Java programmers. Cayenne maps Java classes to database tables and automatically generates SQL to move data back-and-forth between Java objects and the database, which is a tedious task if done manually. An ORM simplifies accessing a relational database (such as Oracle, MySQL, PostgreSQL, SQL Server, H2, etc) and insulates developers from writing common SQL and data marshaling code.

Some of the features of Cayenne include:

Cayenne by Example

Cayenne by Example illustrates some of the major features of the Cayenne framework through small-scale examples. The goal of this book isn't to illustrate every possible aspect of Cayenne, but to illustrate the most common features in order to bootstrap someone into effectively using Cayenne.

Before the examples, however, is an introduction to Cayenne Modeler, which is the primary tool for modeling your database and mapping Java classes to database entities. Following the chapter on Cayenne Modeler is an introduction into Cayenne contexts and then the examples themselves.

Source Code

In addition to this book, there is source code (complete Maven projects) for each example. The source code for these examples is available at GitHub. If you discover an error in the examples or this book and have a GitHub account, please open an issue against the GitHub project so it can be fixed.

Running the Examples

To actually run the code you'll need to download and install the following if you don't already have them:

That's it. Maven will download everything else you need, such as the Cayenne dependencies and the H2 Database.

To download Maven or the Maven Eclipse Plugin, see the links in the Resources section. Downloading Cayenne separately or how to use it with Maven is covered in the next section.

License

This book and the accompanying source code is licensed under the Apache License.

Copyright 2012+ Michael Gentry

Licensed 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.