I am getting a class cast exception running hbm2java on a simple mapping generated using middlegen. I am not sure what this exception indicates has happened. Thank you for your time.
Joel Hillacre
Hibernate version:
hibernate-2.1.6
Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin 2.1
http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->
<class
name="com.tsiware.beans.Testtable"
table="TESTTABLE"
>
<meta attribute="class-description" inherit="false">
@hibernate.class
table="TESTTABLE"
</meta>
<id
name="testcolumn1"
type="java.lang.Long"
column="TESTCOLUMN1"
>
<meta attribute="field-description">
@hibernate.id
generator-class="assigned"
type="java.lang.Long"
column="TESTCOLUMN1"
</meta>
<generator class="assigned" />
</id>
<property
name="testcolumn2"
type="java.lang.Byte"
column="TESTCOLUMN2"
length="4"
>
<meta attribute="field-description">
@hibernate.property
column="TESTCOLUMN2"
length="4"
</meta>
</property>
<property
name="testcolumn3"
type="java.lang.Short"
column="TESTCOLUMN3"
length="6"
>
<meta attribute="field-description">
@hibernate.property
column="TESTCOLUMN3"
length="6"
</meta>
</property>
<property
name="testcolumn4"
type="java.lang.String"
column="TESTCOLUMN4"
length="255"
>
<meta attribute="field-description">
@hibernate.property
column="TESTCOLUMN4"
length="255"
</meta>
</property>
<!-- Associations -->
</class>
</hibernate-mapping>
Full stack trace of any exception that occurs:runhbm2java:
[hbm2java] Processing 1 files.
[hbm2java] Building hibernate objects
[hbm2java] java.lang.ClassCastException
[hbm2java] at net.sf.hibernate.tool.hbm2java.MetaAttributeHelper.mergeMetaMaps(MetaAttributeHelper.java:89)
[hbm2java] at net.sf.hibernate.tool.hbm2java.MetaAttributeHelper.loadAndMergeMetaMap(MetaAttributeHelper.java:110)
[hbm2java] at net.sf.hibernate.tool.hbm2java.ClassMapping.initWith(ClassMapping.java:160)
[hbm2java] at net.sf.hibernate.tool.hbm2java.ClassMapping.<init>(ClassMapping.java:72)
[hbm2java] at net.sf.hibernate.tool.hbm2java.CodeGenerator.handleClass(CodeGenerator.java:128)
[hbm2java] at net.sf.hibernate.tool.hbm2java.CodeGenerator.main(CodeGenerator.java:103)
[hbm2java] at net.sf.hibernate.tool.hbm2java.Hbm2JavaTask.processFile(Hbm2JavaTask.java:145)
[hbm2java] at net.sf.hibernate.tool.hbm2java.Hbm2JavaTask.execute(Hbm2JavaTask.java:95)
[hbm2java] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[hbm2java] at org.apache.tools.ant.Task.perform(Task.java:364)
[hbm2java] at org.apache.tools.ant.Target.execute(Target.java:341)
[hbm2java] at org.apache.tools.ant.Target.performTasks(Target.java:369)
[hbm2java] at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
[hbm2java] at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
[hbm2java] at org.apache.tools.ant.Main.runBuild(Main.java:673)
[hbm2java] at org.apache.tools.ant.Main.startAnt(Main.java:188)
[hbm2java] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
[hbm2java] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)
Build.xml:Code:
<mkdir dir="${gensrc.dir}/${package.dir}/beans"/>
<taskdef
name="hbm2java"
classname="net.sf.hibernate.tool.hbm2java.Hbm2JavaTask"
classpathref="lib.class.path"
/>
<hbm2java output="${gensrc.dir}">
<fileset dir="${gensrc.dir}">
<include name="**/*.hbm.xml"/>
</fileset>
</hbm2java>
Name and version of the database you are using:
MySQL 4.1.7-max