| Title: cdbgen |
| |
| |
| <P><TT>cdbgen</TT> is an Ant task that uses Cayenne DataMap to drop and/or generate schema objects of a specified database.</P> |
| |
| <H3><A name="cdbgen-Parameters"></A>Parameters</H3> |
| <DIV class="table-wrap"> |
| <TABLE class="confluenceTable"><TBODY> |
| <TR> |
| <TH class="confluenceTh">Attribute</TH> |
| <TH class="confluenceTh">Description</TH> |
| <TH class="confluenceTh">Required</TH> |
| </TR> |
| <TR> |
| <TD class="confluenceTd">map</TD> |
| <TD class="confluenceTd">DataMap XML file to use as a schema descriptor.</TD> |
| <TD class="confluenceTd">Yes</TD> |
| </TR> |
| <TR> |
| <TD class="confluenceTd">adapter</TD> |
| <TD class="confluenceTd">Java class implementing <TT>org.apache.cayenne.dba.DbAdapter</TT>. While this attribute is optional (a generic JdbcAdapter is used if not set), it is highly recommended to specify correct target adapter.</TD> |
| <TD class="confluenceTd">No (but strongly recommended)</TD> |
| </TR> |
| <TR> |
| <TD class="confluenceTd">driver</TD> |
| <TD class="confluenceTd">A class of JDBC driver to use for the target database.</TD> |
| <TD class="confluenceTd">Yes</TD> |
| </TR> |
| <TR> |
| <TD class="confluenceTd">url</TD> |
| <TD class="confluenceTd">JDBC connection URL of a target database.</TD> |
| <TD class="confluenceTd">Yes</TD> |
| </TR> |
| <TR> |
| <TD class="confluenceTd">username</TD> |
| <TD class="confluenceTd">Database user name.</TD> |
| <TD class="confluenceTd">No</TD> |
| </TR> |
| <TR> |
| <TD class="confluenceTd">password</TD> |
| <TD class="confluenceTd">Database user password.</TD> |
| <TD class="confluenceTd">No</TD> |
| </TR> |
| <TR> |
| <TD class="confluenceTd">droptables</TD> |
| <TD class="confluenceTd">Defines whether cdbgen should drop the tables before attempting to create new ones. Default is "No".</TD> |
| <TD class="confluenceTd">No</TD> |
| </TR> |
| <TR> |
| <TD class="confluenceTd">droppk</TD> |
| <TD class="confluenceTd">Defines whether cdbgen should drop Cayenne primary key support objects. Default is "No".</TD> |
| <TD class="confluenceTd">No</TD> |
| </TR> |
| <TR> |
| <TD class="confluenceTd">createtables</TD> |
| <TD class="confluenceTd">Defines whether cdbgen should create new tables. Default is "Yes".</TD> |
| <TD class="confluenceTd">No</TD> |
| </TR> |
| <TR> |
| <TD class="confluenceTd">createpk</TD> |
| <TD class="confluenceTd">Defines whether cdbgen should create Cayenne-specific auto PK objects. Default is "Yes".</TD> |
| <TD class="confluenceTd">No</TD> |
| </TR> |
| <TR> |
| <TD class="confluenceTd">createfk</TD> |
| <TD class="confluenceTd">Defines whether cdbgen should create foreign key copnstraints. Default is "Yes".</TD> |
| <TD class="confluenceTd">No</TD> |
| </TR> |
| </TBODY></TABLE> |
| </DIV> |
| |
| |
| <DIV class="panelMacro"><TABLE class="noteMacro"><COLGROUP><COL width="24"><COL></COLGROUP><TR><TD valign="top"><IMG src="http://cayenne.apache.org/docs/1.2/images/icons/emoticons/warning.gif" width="16" height="16" align="absmiddle" alt="" border="0"></TD><TD><B>Driver Classpath</B><BR>Support for "classpath" or "classpathref" attributes is pending. To work around this limitation, JDBC driver (and custom DbAdapter) classpath can be appended to the classpath used to load the task via "taskdef".</TD></TR></TABLE></DIV> |
| |
| <H3><A name="cdbgen-Example"></A>Example</H3> |
| |
| <P>Load the Ant task <EM>(note: if you already loaded all Cayenne tasks via an antlib taskdef <A href="ant-tasks.html" title="Ant Tasks">described before</A>, this step is not needed)</EM>: </P> |
| <DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent"> |
| <PRE class="code-xml"><SPAN class="code-tag"><taskdef name=<SPAN class="code-quote">"cdbgen"</SPAN> classname=<SPAN class="code-quote">"org.apache.cayenne.tools.DbGeneratorTask"</SPAN>></SPAN> |
| <SPAN class="code-tag"><classpath refid=<SPAN class="code-quote">"classpath"</SPAN>/></SPAN> |
| <SPAN class="code-tag"></taskdef></SPAN></PRE> |
| </DIV></DIV> |
| |
| <P>Here is an example of using <TT>cdbgen</TT> to create DB schema objects on a local HSQLDB.</P> |
| |
| <DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent"> |
| <PRE class="code-xml"><cdbgen map=<SPAN class="code-quote">"${context.dir}/WEB-INF/DefaultMap.map.xml"</SPAN> |
| adapter=<SPAN class="code-quote">"org.apache.cayenne.dba.hsqldb.HSQLDBAdapter"</SPAN> |
| driver=<SPAN class="code-quote">"org.hsqldb.jdbcDriver"</SPAN> |
| url=<SPAN class="code-quote">"jdbc:hsqldb:hsql://localhost/bookmarker"</SPAN> |
| username=<SPAN class="code-quote">"sa"</SPAN>/> |
| </PRE> |
| </DIV></DIV> |