We have an existing and working database created from hbm mapping files.
We want to create some new tables for an optional feature.
One option is that these new tables always exist but we would prefer for the tables and POJOs to only be created on request.
My issue is that these tables/POJOs have dependancies on existing tables/POJOs. I have created a mapping file but I can only get it to work if it creates create/drop commands for the existing tables as well as the new ones,
along with their POJOs as well.
Can I avoid this. In the example below Group is an existing table/POJO.
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping
package="uk.co.foo.disconnections.domain.dfwv">
<class name="DisconTest" table="DISCON_TEST">
<id name="id" type="java.lang.Long">
<column name="ID" not-null="true" />
</id>
<many-to-one name="group"
class="uk.co.foo.domain.dfwv.Group"
foreign-key="GROUP_FK" lazy="false" not-found="ignore">
<meta attribute="use-in-tostring">false</meta>
<column name="GROUP_NAME"
not-null="true" />
</many-to-one>
</class>
</hibernate-mapping>
The ant target to generate this is below and only works if the dependant objects are listed:
Code:
<target name="discon_dfwv_pojoexport" description="Creates domain objects for Disconnection DF.Web Vista based on Hibernate mapping files" >
<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="class.path" />
<hibernatetool destdir="${src.dir}">
<configuration>
<fileset dir="${discon.dfwv.mappings.dir}">
<include name="**/*.hbm.xml" />
</fileset>
<fileset dir="${dfwv.mappings.dir}">
<include name="**/groups.hbm.xml" />
</fileset>
</configuration>
<hbmtemplate exporterclass="uk.co.foo.hibernateutils.tools.Exporter" templateprefix="config/foopojo/" template="config/foopojo/Pojo.ftl">
<property key="jdk5" value="true" />
<property key="ejb3" value="false" />
</hbmtemplate>
</hibernatetool>
</target>
Without the dependant reference to Group then I get the error:
Code:
BUILD FAILED
C:\projects\foo\db-build.xml:187: Schema text failed: An association from the table DISCON_TEST refers to an unmapped class: uk.co.foo.domain.dfwv.Group
Hibernate version:3.1.2Code: