cdbimport is an Ant task that that uses Cayenne to generate a DataMap based on an existing database schema. This allows you to generate your DataMap prior to building your project, which may be necessary if you are also using the cgen task.

Parameters

Attribute Description Required
map DataMap XML file to use as a schema descriptor. Yes
overwriteExisting Indicates whether existing DB and object entities should be overwritten. This is an all-or-nothing setting. If you need finer granularity, please use the Cayenne Modeler. Default is true. No
schemaName Database schema to use for importing. No
tablePattern Pattern to match tables against for import. Default is to match all tables. No
importProcedures Indicates whether stored procedures should be imported. Default is false. No
procedurePattern Pattern to match stored procedures against for import. Default is to match all stored procedures. This value is only meaningful if importProcedures is true. No
meaningfulPk Indicates whether primary keys should be mapped as attributes of the object entity. Default is false. No
namingStrategy The naming strategy used for mapping database names to object entity names. Default is org.apache.cayenne.map.naming.SmartNamingStrategy. No
adapter Java class name 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

Example

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

<cdbimport 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"/>