I am having an unusual problem with hibernate-tools-3.0.0.0alpha4a and UserType generation.
I set up the hbm2java task in my ant file as follows:
Code:
<target name="hbm2java"
description="Creates model POJOs in build from hbm.xml files" depends="compile-src">
<taskdef
name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="hibernatetools.path"/>
<hibernatetool destdir="./build">
<classpath>
<path location="./bin"/>-->
</classpath>
<configuration>
<fileset dir="./mappings"> <!-- A configuration can take a configurationfile and/or a fileset of hbm.xml's -->
<include name="**/*.hbm.xml"/>
</fileset>
</configuration>
<hbm2java generics="false"/> <!-- generate default .java files -->
</hibernatetool>
</target>
Note that the task calls compile-src, which compiles the UserType files into the directory
bin before attempting to do any generation. Also note that I have explicitly turned off generics mode.
Somehow, I get the following exception:
Code:
[hibernatetool] (hbm2x.Cfg2JavaTool 574 )
Could not resolve type without exception for org.hibernate.mapping.Property(country) Value: org.hibernate.mapping.SimpleValue
([org.hibernate.mapping.Column(countryid)]) Type: null.
Falling back to typename: com.acme.persistence.model.CountryCodeUserType
Finding class com.acme.persistence.model.CountryCodeUserType
Finding class com.acme.persistence.model.CountryCodeUserType
If I'm correct, the exception is being thrown from line 574 (commented) in
org.hibernate.tool.hbm2x.Cfg2JavaTool, which is actually within a block of code that seems like it should only be executed when
generics mode is on:
Code:
if (useGenerics) {
if (value instanceof Collection) {
Collection collection = (Collection) value;
OneToMany oneToMany = (OneToMany) collection.getElement();
String entityType = oneToMany.getAssociatedClass().getClassName(); //!! Line 574
return toName(p.getType().getReturnedClass() ) + "<" + entityType + ">";
}
}
Maybe my investigation has missed something. Anyhow, any help is deeply appreciated.