Title: cdataport
Sometimes it is necessary to recreate a database, copying data from another existing database. For instance, recreating development database instance from production data, etc. While most RDBMS provide data import/export tools, they normally require advanced DBA skills to use and are most often not portable across database engines. Cayenne will provide a lightweight ant task to do data porting between the databases with identical schema, using DataMap information.
cdataport is an Ant task that takes a Cayenne project (cayenne.xml) with at least one DataMap and two DataNodes and ports data from source DataNode to a destination DataNode. All DataMaps linked to either the source or the target DataNode will be considered for porting.
Attribute | Description | Required |
---|---|---|
projectFile | Location of Cayenne project file containing mapping. | Yes |
maps | A comma-separated list of DataMap names within the project, whoose entities data needs to be ported. If ommitted, all DataMaps in the project will be ported. | No |
srcNode | Source DataNode name. | Yes |
destNode | Destination DataNode name. | Yes |
cleanDest | If false, will skip deleting data from the destination tables. True is default. | No |
includeTables | Comma-separated list of tables to include in the port. If ommitted, all mapped DbEntities will be used. It is possible to use "*" to indicate name patterns. | No |
excludeTables | Comma-separated list of tables to exclude from the port. If ommitted, all mapped DbEntities will be used. It is possible to use "*" to indicate name patterns. | No |
Here is an example of using cdataport to port data using all source DataMaps, excluding DBEntities with name matching "BILL_*":
<taskdef name="cdataport" classname="org.objectstyle.cayenne.tools.DataPortTask"> <classpath refid="classpath"/> </taskdef> <cdataport projectFile="subdir/cayenne.xml" srcNode="ProductionNode" destNode="DevNode" excludeTables="BILL_*"/>