Template structure

For each target you can have several files which are generated. There is a ini file which contains the list of files which need to be generated.
This ini file is called "target-name.ini" and is searched on the classpath.

The file has the following format (excerpt from the ejb3.ini)






// build entity bean

// build session facade bean

// build session facade root mediator

// build SelectorHelper classes


// build mediator base class (generated)

// build mediator class (for manual modification)


// build entity bean

The "config" section indicates the path which is prepended to each template file. The templates are all retrieved from the classpath, but the prefix allows you to avoid name collisions (like java packages).

All the other sections indicate the possible groupings in the domain model for which files can be generated.
The can contain outputX, templateX and skip-ifX where X is a number from 1 up to the amount needed (needs to be consecutive). In the parameters, you can use variable replacement using the ant/velocity syntax "${var-name}

  • output indicates the location where the output file needs to be searched
  • template indicates the template file which needs to be used to produce the output
  • skip-if allows you to skip the template generation if the file with given name already exists.

The sections which can be used (including variables for output names and templates) are

  • global : these templates are invoked once.
  • table : these are generated for each table. "table" is the table name for the filenames, of a Table object for the velocity templates.
  • root-table : these are generated for each roottable. "table" is the (root) table name for the filenames, of a RootTable object for the velocity templates.
  • root-table-expected-amount-small : same as "root-table" but only when the expected amount on the root is "small".
  • root-table-with-inheritance : same as "root" but only when the inheritance tree has more than one table.
  • field : each field, has "root-table" variables and "field" name for filenames or Field instance in the templates.
  • field-with-choices : same as "field" but only for fields with choices.
  • select-not-hidden : all selects which are not hidden, has "root-table" variables and "select" name for filenames or Select instance in the templates.
  • action-not-hidden : all actions which are not hidden, has "root-table" variables and "action" name for filenames or Action instance in the templates.

For variable replacement in the filenames, the following are available in all cases.

  • packageName
  • packageDir
  • outputDir
  • altOutputDir

The following variables are always available in te Velocity templates.

  • engine : a reference to the Generator class.
  • name : "equanda'.
  • dollar : "$".
  • dm, data : the actual domain model, instance of the DomainModel class.
  • package : the package name, as passed in the (template specific) configuration. If not defined there, then the "ejb-package" setting from the "extra" sectio is used.
  • generationdate : string representation of the time when the generation started.
  • keyvalue : the keyvalue pairs which are passed in the (template specific) configuration.
  • dbtype : an instance of the convert class as determined in the "database" section.