Cayenne User Documentation
Tutorial

## Tutorial

This is a step-by-step tutorial showing how to write a database application with Cayenne. When you are done with it, you should have an understanding of the basics of object-relational mapping using CayenneModeler and how to use the Cayenne framework in standalone (command-line or otherwise) and web applications. The tutorial uses Maven, Eclipse IDE and Derby database, however it can be easily recreated with another combination of a database, an IDE and a build system. Full tutorial source code in a form of Eclipse project is distributed with Cayenne (see `"tutorials/tutorial"` folder).

| Note about Maven The only potentially controversial choice here is Maven. Not everybody is familiar with Maven, and not everybody likes it. However we decided that the benefits of the setup simplicity outweigh any downsides. Note that the tutorial is using `m2eclipse` plugin and doesn't even require a command-line Maven installation. Moreover most of the useful Cayenne Maven hackery is presented in boxed inserts throughout the text, while a Maven-agnostic alternative is shown in the main text.

### Sections

1. Setting up the environment...
2. Learning mapping basics
   1. Starting a project...
   2. Getting started with Object Relational Mapping (ORM)...
   3. Creating Java classes...
3. Learning Cayenne API
   1. Getting started with ObjectContext...
   2. Getting started with persistent objects...
   3. Selecting objects...
   4. Deleting objects...
4. Converting to web application...

.
Copyright ©2001-2010 Apache Software Foundation