-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: mapping file with dependancies to existing tables/POJOs
PostPosted: Tue Mar 31, 2009 11:24 am 
Newbie

Joined: Sun Apr 06, 2008 10:58 am
Posts: 4
Location: UK
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.2
Code:


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.