Cayenne User Documentation
Generate Java Classes

First we'd like to mention an alternative way of generating classes from the model, that can save time in many situtations compared to using the GUI: cgen Ant task would automatically refresh generated classes when needed during the build.

To generate classes from the Modeler, you must select either a DataMap or an ObjEntity in the project tree and then select `"Tools > Generate Classes"` from the menu. A "Code Generation" dialog opens:

It has two tabs - "Code Generator" for setting generator parameters, and "Entities" for entity selection. If you had an ObjEntity selected prior to opening the dialog, only this entity will be selected. Otherwise all entities that do not have validation failures will be selected. Users of course can change the selection to run generator for an arbitrary subset of entities.

Generator provides three modes of operation that can be chosen from the "Type:" dropdown.

### "Standard Persistent Objects" Generation Mode

The first type, shown above, is "Standard Persistent Objects" - it will generate class pairs ("auto" superclass, and an empty subclass that can be later customized by users). All you need is to select a root directory of your source code (nested package subdirectories will be created automatically), and check that the default superclass package is what you want. If you previously set a Java package for the DataMap, the default superclass package will appen ".auto" to that package name

### "Client Persistent Objects" Generation Mode

"Client Persistent Objects" type is not much different from the standard objects type. The main difference is that it uses a template appropriate for the client classes for applications using remote object persistence. Default entity selection is also different - only entities that are allowed to be used on the client are preselected.

### "Advanced" Generaton Mode

As the name implies this mode allows much more customization of the generation procedure, such as custom Velocity templates (that are configured in Modeler Preferences), single run per entity or single run for the entire DataMap, etc. The options available in the dialog closely mirror those of the cgen Ant task.

.
Copyright ©2001-2008 Apache Software Foundation