PriDE Ant Task


Users of the build-tool Ant can use a special Ant task to run PriDE's entity generator from an Ant build script. The task class is bundled in PriDE's runtime library, so it is sufficient to have this library added to the classpath to have the task class available. The task can be definied by Ant's taskdef-task like this:

<target name="taskdef" description="Define the PriDE task">
    <taskdef name="pride" classname="de.mathema.pride.util.ant.PrideGen" />
</target>


Parameters

Attribute
Description
Required
driver
Name of the JDBC driver class for database access
Yes
url
Name/URL of the database to access
Yes
user
Database login name
No
password
Password for the login name specified above
No
table
Name of the database table which to generate an entity class for. This parameter can also be specified as a nested element to address multiple tables. Multiple tables are required for the mapping of joins.
Yes
class
Name of the class to generate, including the full package specification if requested. If there is only a single database table addressed by parameter table, the class parameter defaults to the table name. The package path for the class will automatically be created by the task if not yet existing. The directory structure is built relative sourceBase (see below).
Yes, in case of multiple tables
baseClass
Optional name of a base class from which to derive the generated one. Data members and mappings are only generated for database fields which are not already mapped by the base class. The specified class must have been already compiled and must be available from the class path. When generating a value type only (mode="bean"), the corresponding base adapter type must be specified.
No
beanClass
Only required when generating pure adapter classes. Specifies the name of the bean class to refer to in the adapter. The specified class must have been already compiled and must be available from the class path.
Yes, for adapter generation
sourceBase
Base directory for the source code creation. If this parameter is ommited, package directories and entity files are created relative from the current project directory.
No
mode
Generator mode. Value "hybrid" generates a hybrid entity type including both a record descriptor and the data members. Value "bean" generates a pure value type, including only the data members. Value "adapter" generates a pure mapping type making use of a seperate bean type to store the data. This mode requires the bean type to be specified by parameter beanClass. See PriDE-Patterns-Decoupling.html for further details concerning hybrid and decoupled entity types. Default mode is "hybrid".
No

Parameters specified as nested elements

table
Specification of a database table to create an entity for. Specifiying this element multiple times allows to address all specified tybles at once in a joined type. Each table element requires a name attribute specifiying the database table name. See PriDE-Patterns-Join.html for further information on joins.

classpath
Java's classpath attribute is a PATH-like structure

Examples

Create a hybrid entity type de.test.Customer from a table customer in a MySQL test database

<pride
    driver="com.mysql.jdbc.Driver"
    url="jdbc:mysql://localhost/test"
    class="de.test.Customer"
    table="customer" />


Create a bean type for the same table, specifying the table in a nested element

<pride
    driver="com.mysql.jdbc.Driver"
    url="jdbc:mysql://localhost/test"
    class="de.test.CustomerBean"
    mode="bean">
    <table name="customer" />
</pride>


Create a corresponding adapter type, assuming that the bean type has already been compiled

<pride
    driver="com.mysql.jdbc.Driver"
    url="jdbc:mysql://localhost/test"
    mode="adapter"
    table="customer"
    class="de.test.CustomerDBA"
    beanClass="de.test.CustomerBean">
    <classpath>
        <pathelement location="." />
        <pathelement path="${java.class.path}" />
    </classpath>
</pride>



Home Introduction Javadoc