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

Custom Templates

Cayenne Version 3.0.2
Project Directory Templates (contains Velocity templates)
Source Directories Templates/src/main/java
Resource Directory Templates/src/main/resources
Inputs N/A
Compiling/Running cd Templates
mvn cayenne:cgen
View/Edit Model mvn cayenne-modeler:run
Status Code: Completed
Documentation: In-Progress

Cayenne includes default Velocity-based templates used to generate your Cayenne classes from the model. These default templates are sufficient for most uses, but you can create custom templates if desired.

This GitHub directory contains example custom templates, superclass.vm and subclass.vm, for Cayenne superclasses and subclasses. These are based upon the original templates, but have the following changes:

To use these (or other) custom templates, put a copy in your project and add them to your Cayenne Modeler preferences under the Templates section as "subclass" and "superclass". (If you use different names, substitute the different names below.)

When generating classes, use the Advanced option with the following suggested settings:

Generation Mode: Entity and Embeddable generation
Generator Version: 1.2
Subclass Template: subclass (or your different template name)
Superclass Template: superclass (or your different template name)
Output Pattern: *.java
Make Pairs: checked
Overwrite Subclasses: unchecked
Use Package Path: checked