When using net.sf.hibernate.tool.hbm2java.CodeGenerator, if I use any meta tags in the mapping file, I get a ClassCastException when running the codegen. If I comment out all meta tags, it works fine.
I'm using v2.0.3 of the hibernate.jar and v2.1 of the hibernate tools.
It seemed I had to build the hibernate-tools.jar locally to get the hbm2java class in the hibernate-tools.jar. Maybe this is my problem??
Is there a version of the hibernate-tools.jar that includes the hmb2java?
Thanks in advance for any help...
Here's the mapping with a single meta tag UNcommented:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<meta attribute="extends">com.medengineering.bus.vo.HibernateVOImpl</meta>
<!--meta attribute="implements">com.medengineering.bus.vo.HibernateVO</meta-->
<class name="com.medengineering.bus.vo.CatalogItemVO"
table="catalog_item">
<!--meta attribute="class-description">
Items for the catalog
@author jay
</meta-->
<id name="id" type="long">
<generator class="increment"/>
</id>
<property name="catalogItemName" type="string">
<!--meta attribute="field-description">
The item's name as will be displayed in search results etc.
</meta-->
</property>
<property name="descLong" type="string">
<!--meta attribute="field-description">Long description. May contain HTML.</meta-->
</property>
<many-to-one name="category" column="category_id"
class="com.medengineering.bus.vo.CatalogCategoryVO">
</many-to-one>
<set name="images" inverse="true">
<key column="catalog_item_id"/>
<one-to-many class="com.medengineering.bus.vo.CatalogImageVO"/>
</set>
</class>
<class name="com.medengineering.bus.vo.CatalogCategoryVO"
table="catalog_category">
<!--meta attribute="class-description">Category</meta-->
<id name="id" type="long">
<generator class="increment"/>
</id>
<property name="categoryName" type="string">
<!--meta attribute="field-description">short category name</meta-->
</property>
<property name="parentId" type="java.lang.Long" column="parent_id" insert="false" update="false"/>
<set name="catalogItems" inverse="true">
<key column="category_id"/>
<one-to-many class="com.medengineering.bus.vo.CatalogItemVO"/>
</set>
<set name="subCategories" inverse="true" >
<key column="parent_id"/>
<one-to-many class="com.medengineering.bus.vo.CatalogCategoryVO"/>
</set>
<many-to-one name="parentCategory" column="parent_id" class="com.medengineering.bus.vo.CatalogCategoryVO" >
</many-to-one>
</class>
<class name="com.medengineering.bus.vo.CatalogImageVO"
table="catalog_image">
<id name="id" type="long">
<!--meta attribute="scope-set">
protected
</meta-->
<generator class="increment"/>
</id>
<property name="imageType" type="int"/>
<property name="description" type="string">
<!--meta attribute="field-description">
Some description of the image
</meta-->
</property>
<property name="imagedata" type="blob"/>
<many-to-one name="parentItem" column="catalog_item_id" class="com.medengineering.bus.vo.CatalogItemVO"/>
</class>
</hibernate-mapping>
Here's the stack trace:
Code:
java.lang.ClassCastException
at net.sf.hibernate.tool.hbm2java.MetaAttributeHelper.mergeMetaMaps(MetaAttributeHelper.java:89)
at net.sf.hibernate.tool.hbm2java.MetaAttributeHelper.loadAndMergeMetaMap(MetaAttributeHelper.java:110)
at net.sf.hibernate.tool.hbm2java.ClassMapping.initWith(ClassMapping.java:86)
at net.sf.hibernate.tool.hbm2java.ClassMapping.<init>(ClassMapping.java:73)
at net.sf.hibernate.tool.hbm2java.CodeGenerator.main(CodeGenerator.java:99)
Here's the ant target:
Code:
<target name="codegen-catalog" description="generate the VO code for the catalog">
<java classname="net.sf.hibernate.tool.hbm2java.CodeGenerator"
fork="true"
failonerror="true">
<classpath>
<path refid="base.path"/>
</classpath>
<arg value="--output=${src.java}"/>
<arg value="${conf.dir}/hibernate-catalog-map.hbm.xml"/>
</java>
</target>