Hi I am newbie to Hibernate. I got to upgrade the Hibernate version from 2.1.6 to 3.
While upgrading to HB 3, I had to replace the hbm2java task[net.sf.hibernate.tool.hbm2java.Hbm2JavaTask] with hibernatetool[org.hibernate.tool.ant.HibernateToolTask]
Code:
<taskdef
name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="hibernate.lib"/>
<hibernatetool destdir="${hibernate.build}">
<configuration>
<fileset dir="${hibernate.src}">
<include name="**/*.hbm.xml" />
</fileset>
</configuration>
<hbm2java/> <!-- generate default .java files -->
</hibernatetool>
Earlier when .java source file were generated by using hbm2java, the collection properties in the *.hbm.xml files were observed to be of
java.util.List data type in the .java source files. My *.hbm.xml files make use of <idbag/> element for collections as shown in code below:
Code:
<idbag name="details" table="RealmL10n" lazy="true">
<cache usage="nonstrict-read-write"/><!-- Should be read-only -->
<collection-id type="long" column="realm_l10n_guid">
<meta attribute="scope-set">protected</meta>
<generator class="com.abc.persistence.GuidGenerator"/>
</collection-id>
<key column="realmId_guid" foreign-key="FK_REALML10N_REALM"/>
-------------------------------------------------
-------------------------------------------------
</idbag>
The new tool generates them as
java.util.Collection data type.
The existing code that consumes the Java source files(Generated from .hbm.xml) expects the List rather than Collection data type. I can't go and change all the consumer code. ( This can only be considered as the last option).
Can anyone please suggest how should I generate the Java Source files using the new tool so that they generate the java.util.List properties rather than java.util.Collection properties?