| Title: maven2-cdbgen |
| |
| <P><TT>cdbgen</TT> is an Maven 2 mojo that that uses Cayenne DataMap to drop and/or generate schema objects of a specified database. By default, it is bound to the <TT>pre-integration-test</TT> phase. Please see this <A href="http://docs.codehaus.org/display/MAVENUSER/Maven%20and%20Integration%20Testing" class="external-link" rel="nofollow">guide to integration testing with maven2</A> for ideas of how tie this in with your existing test infrastructure.</P> |
| |
| <H3><A name="maven2-cdbgen-Parameters%28asXMLelements%29"></A>Parameters (as XML elements)</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 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.</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> |
| |
| |
| |
| <H3><A name="maven2-cdbgen-Examples"></A>Examples</H3> |
| |
| <P>Load the Maven 2 plugin and configure the <TT>cdbgen</TT> mojo: </P> |
| |
| <DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent"> |
| <PRE class="code-xml"> |
| <SPAN class="code-tag"><build></SPAN> |
| <SPAN class="code-tag"><plugins></SPAN> |
| <SPAN class="code-tag"><plugin></SPAN> |
| <SPAN class="code-tag"><groupId></SPAN>org.apache.cayenne.plugins<SPAN class="code-tag"></groupId></SPAN> |
| <SPAN class="code-tag"><artifactId></SPAN>maven-cayenne-plugin<SPAN class="code-tag"></artifactId></SPAN> |
| <SPAN class="code-tag"><executions></SPAN> |
| <SPAN class="code-tag"><execution></SPAN> |
| <SPAN class="code-tag"><id></SPAN>cdbgen<SPAN class="code-tag"></id></SPAN> |
| <SPAN class="code-tag"><configuration></SPAN> |
| <SPAN class="code-tag"><SPAN class="code-comment"><!-- Configuration items go in here. See table, above. --></SPAN></SPAN> |
| <SPAN class="code-tag"></configuration></SPAN> |
| <SPAN class="code-tag"><goals></SPAN> |
| <SPAN class="code-tag"><goal></SPAN>cdbgen<SPAN class="code-tag"></goal></SPAN> |
| <SPAN class="code-tag"></goals></SPAN> |
| <SPAN class="code-tag"></execution></SPAN> |
| <SPAN class="code-tag"></executions></SPAN> |
| <SPAN class="code-tag"></plugin></SPAN> |
| <SPAN class="code-tag"></plugins></SPAN> |
| <SPAN class="code-tag"></build></SPAN> |
| </PRE> |
| </DIV></DIV> |
| |
| <P>Here is an example of using <TT>cdbgen</TT> to create DB schema objects on a local HSQLDB database named "bookmarker" from a DataMap located in "main/resources/datamap.map.xml":</P> |
| <DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent"> |
| <PRE class="code-xml"> |
| <SPAN class="code-tag"><build></SPAN> |
| <SPAN class="code-tag"><plugins></SPAN> |
| <SPAN class="code-tag"><plugin></SPAN> |
| <SPAN class="code-tag"><groupId></SPAN>org.apache.cayenne.plugins<SPAN class="code-tag"></groupId></SPAN> |
| <SPAN class="code-tag"><artifactId></SPAN>maven-cayenne-plugin<SPAN class="code-tag"></artifactId></SPAN> |
| <SPAN class="code-tag"><executions></SPAN> |
| <SPAN class="code-tag"><execution></SPAN> |
| <SPAN class="code-tag"><id></SPAN>cdbgen<SPAN class="code-tag"></id></SPAN> |
| <SPAN class="code-tag"><configuration></SPAN> |
| <SPAN class="code-tag"><map></SPAN>${project.build.sourceDirectory}/../resources/datamap.map.xml<SPAN class="code-tag"></map></SPAN> |
| <SPAN class="code-tag"><adapter></SPAN>org.apache.cayenne.dba.hsqldb.HSQLDBAdapter<SPAN class="code-tag"></adapter></SPAN> |
| <SPAN class="code-tag"><driver></SPAN>org.hsqldb.jdbcDriver<SPAN class="code-tag"></driver></SPAN> |
| <SPAN class="code-tag"><url></SPAN>jdbc:hsqldb:hsql://localhost/bookmarker<SPAN class="code-tag"></url></SPAN> |
| <SPAN class="code-tag"><username></SPAN>sa<SPAN class="code-tag"></username></SPAN> |
| <SPAN class="code-tag"></configuration></SPAN> |
| <SPAN class="code-tag"><goals></SPAN> |
| <SPAN class="code-tag"><goal></SPAN>cdbgen<SPAN class="code-tag"></goal></SPAN> |
| <SPAN class="code-tag"></goals></SPAN> |
| <SPAN class="code-tag"></execution></SPAN> |
| <SPAN class="code-tag"></executions></SPAN> |
| <SPAN class="code-tag"></plugin></SPAN> |
| <SPAN class="code-tag"></plugins></SPAN> |
| <SPAN class="code-tag"></build></SPAN> |
| </PRE> |
| </DIV></DIV> |