Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
Hibernate Tools 3.1.0.beta4
hibernate-annotations-3.1beta8
Hibernate 3.1
I am trying to reverse engineer an annotation configuration into a set of .hbm files using the
hbm2hbmxml exporter in hibernate tools.
The results are a set of invalid .hbm files which don't validation against the DTD's. It seems that the many-to-one declarations and various other attributes seem to not get generated..
For example:
Code:
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 23/03/2006 22:59:49 by Hibernate Tools 3.1.0.beta4 -->
<hibernate-mapping>
<class name="com.dytech.pems.model.claim.ClaimType" table="ClaimType">
<id name="id" type="java.lang.Long">
<column name="id" />
<generator class="native"></generator>
</id>
<property name="historicalId" type="java.lang.Long" update="false">
<column name="historicalId" />
</property>
<set name="budgetTypes" inverse="false">
<key>
<column name="ClaimType_id" not-null="true" />
</key>
</set>
</class>
</hibernate-mapping>
The interesting thing is that if I run the schema export to the database all the tables etc, get generated as we expect. I then use the
jdbcconfiguration and get something that is fairly close to what I wanted with the correct mappings and all the missing attributes getting generated.
The documentation suggests that you can use any type of configuration and convert to .hbm files.
ant task:Code:
<hibernatetool destdir="${build.dir}/hbmTemp">
<classpath >
<pathelement location="${classes.dir}"/>
<path refid="hibernate.tools.classpath" />
</classpath>
<annotationconfiguration configurationfile="${config.dir}/hibernate.cfg.xml"/>
<hbm2hbmxml/>
</hibernatetool>
hibernate config:Code:
<session-factory>
<property name="connection.url">jdbc:jtds:sqlserver://eris:1433/dev</property>
<property name="connection.username">username</property>
<property name="connection.password">password</property>
<property name="connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property>
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.hbm2ddl.auto">create</property>
<mapping class="model.budget.BudgetType" />
... etc
</session-factory>
</hibernate-configuration>