This chapter provides a step-by-step tutorial on writing a full database application with Cayenne. When you are done with it, you should have an understanding of the basics of object relational mapping with CayenneModeler and how to use Cayenne in standalone (command line or otherwise) and web applications. The tutorial uses the Eclipse IDE (since it is free and very common) and Derby database (since it supports embedded mode and thus requires zero setup), however it can be easily applied to any other database and/or IDE's.

Full tutorial source code in a form of Eclipse project is distributed with Cayenne (see "src/tutorials/quick-start" folder).

Sections

  1. Setting up the environment...
  2. Learning mapping basics
    1. Starting mapping project...
    2. Getting started with Object Relational Mapping (ORM)...
    3. Creating database schema and Java classes...
  3. Learning Cayenne API
    1. Getting started with DataContext...
    2. Getting started with persistent objects...
    3. Cleaning up the database on startup...
    4. Selecting objects...
    5. Deleting objects...
  4. Converting to web application...