"No type name" MappingException message is far too cryptic
----------------------------------------------------------
Key: HBX-1054
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HBX-1054
Project: Hibernate Tools
Issue Type: Improvement
Components: hbmlint
Affects Versions: 3.2.1
Reporter: Darryl Miles
Priority: Minor
Having to resort to stepping into Hibernate code to find where this exception is making
hard work for developers. Basically the problem is that the message does not inform the
developer exactly which class and which column has the problem (so we need some context
information emitted with the "No type name"). The rest of the method does have
code to generate a useful exception message if(result==null){}
http://fisheye.labs.jboss.com/browse/Hibernate/core/tags/hibernate-3.3.0....
public Type getType() throws MappingException {
if (typeName==null) {
throw new MappingException("No type name");
}
Type result = TypeFactory.heuristicType(typeName, typeParameters);
if (result==null) {
String msg = "Could not determine type for: " + typeName;
if(table != null){
msg += ", at table: " + table.getName();
}
if(columns!=null && columns.size()>0) {
msg += ", for columns: " + columns;
}
throw new MappingException(msg);
}
return result;
}
Example mapping that cause the problem:
<class name="domain.MyData" table="my_data">
<id name="myDataId" type="long"
column="my_data_id">
<generator class="native" />
</id>
<list name="abcList" table="my_data_list"
cascade="all-delete-orphan">
<key column="my_data_id"/>
<index column="sort_order"/>
<element column="value" not-null="true" /> <!--
type="" was missing here! -->
</list>
</class>
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira