Hi
I am (was) having a weird promblem with the hbm2java ant task.  I tried looking for info on the web, but found nothing.  I'm a complete newby at Hibernate, so if any of this is old news to people, I appologise.
The problem is that the ant task (hbm2java) was crashing while processing the following snippet:
Code:
<class name="patient" table="patient">
      <id name="patientID" type="int" >
         <generator class="sequence" />
      </id>
      <property name="firstName" type="string" length="64" not-null="true" />
      <property name="lastName" type="string" length="64" not-null="true" />
      <property name="medRecNum" type="string" length="64" not-null="true" />
      <property name="dob" type="date" not-null="true" />
      <property name="heightFt" type="int" not-null="true" />
      <property name="heightIn" type="int" not-null="true" />
      <set name="visits">
         <key column="patientID" />
         <many-to-many column="visitID" unique="true" class="visit" />
      </set>
   </class>
   <class name="visit" table="visit" >
      <id name="visitId" column="visitiId" type="int" >
         <generator class="sequence" />
      </id>
   </class>
It was failing with a class cast exception:
Code:
[hibernatetool] java.lang.ClassCastException: org.hibernate.mapping.ManyToOne
[hibernatetool]         at org.hibernate.tool.hbm2x.Cfg2JavaTool.getRawTypeName(Cfg2JavaTool.java:594)
[hibernatetool]         at org.hibernate.tool.hbm2x.Cfg2JavaTool.getJavaTypeName(Cfg2JavaTool.java:494)
[hibernatetool]         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[hibernatetool]         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
I tried applying this 
http://opensource.atlassian.com/projects/hibernate/browse/HBX-224 .  No luck.  After digging arount the latest CVS checkout of HibernateExt, I narrowed the problem to a block of code at approximately line 600 of Cfg2JavaTool.java.  There's a line that's trying to cast a variable to a OneToMany.
Code:
OneToMany oneToMany = (OneToMany) collection.getElement();
At runtime though, the variable is of type ManyToOne.  Hence the class cast exception.  So what I did was check for the variable type.:
Code:
Object temp = collection.getElement();
                            //OneToMany oneToMany = (OneToMany)temp;
                            String entityName = null;
                            if(temp instanceof ManyToOne)
                            {
                                entityName = ((ManyToOne)temp).getReferencedEntityName();
                            }
                            else if(temp instanceof OneToMany)
                            {
                                entityName = ((OneToMany)temp).getReferencedEntityName();
                            }
So umm.... do I get a cookie? :)
Hopefully this will help someone.
Also, how come the patch for another bug 
http://opensource.atlassian.com/projects/hibernate/browse/HBX-224 is not in CVS?