Cayenne User Documentation
cdbgen

`cdbgen` is an Ant task that uses Cayenne DataMap to drop and/or generate schema objects of a specified database.

### Parameters

Attribute | Description | Required
--- | --- | ---
map | DataMap XML file to use as a schema descriptor. | Yes
adapter | Java class implementing `org.apache.cayenne.dba.DbAdapter`. While this attribute is optional (a generic JdbcAdapter is used if not set), it is highly recommended to specify correct target adapter. | No (but strongly recommended)
driver | A class of JDBC driver to use for the target database. | Yes
url | JDBC connection URL of a target database. | Yes
username | Database user name. | No
password | Database user password. | No
droptables | Defines whether cdbgen should drop the tables before attempting to create new ones. Default is "No". | No
droppk | Defines whether cdbgen should drop Cayenne primary key support objects. Default is "No". | No
createtables | Defines whether cdbgen should create new tables. Default is "Yes". | No
createpk | Defines whether cdbgen should create Cayenne-specific auto PK objects. Default is "Yes". | No
createfk | Defines whether cdbgen should create foreign key copnstraints. Default is "Yes". | No
classpath | The classpath used by the task. | No
classpathref | The classpath reference used by the task. | No

### Example

Here is an example of using `cdbgen` to create DB schema objects on a local HSQLDB.

    <cdbgen map="${context.dir}/WEB-INF/DefaultMap.map.xml"
        adapter="org.apache.cayenne.dba.hsqldb.HSQLDBAdapter"
        driver="org.hsqldb.jdbcDriver"
        url="jdbc:hsqldb:hsql://localhost/bookmarker"
        username="sa"/>

.
Copyright ©2001-2010 Apache Software Foundation