Generate Code

To generate code, select Language > Generate Java code (Ctrl + G).Specify the directory where you want to put your generated code. On the Targets tab, make sure the O/R Mapping target is selected.

Select Model Elements

Select model elements to be generated on the Selection tab. The model should be selected for there are some important artifacts generated on the model level, such as persistence configuration file, DAO factory classes, DAO base classes etc.



Define Generation Options

  • Define generation options on the Options tab.



Option

Description

Generate DAO sources

Specifies whether DAO sources should be generated.

Generate Eclipse project artifacts

Specifies whether Eclipse project file and classpath file should be generated.

Generate unit test sources

Specifies whether unit test sources should be generated.

Java source directory

Specifies directory for Java sources.

Test source directory

Specifies directory for unit test sources.

Generate schema validation files

Specifies whether schema file and validation script should be generated.

Generate Ant build.xml file

Specifies whether Ant build.xml file should be generated.

Preview Generated File List

You can get a preview of generated file list on the Generated files tab.

Specify Post Generation Tasks

There are some tasks that can be run after the generation. You can select them on Tasks tab. The useful one is Run generated unit tests. PowerDesigner will run unit tests by Ant script generated after generation if you select the task. You can also run it on the command window. There are some prerequisites before you can run the task. We will show you how to run unit tests in the coming section.