[hibernate-issues] [Hibernate-JIRA] Commented: (HBX-1054) "No type name" MappingException message is far too cryptic

Darryl Miles (JIRA) noreply at atlassian.com
Mon Mar 31 09:58:33 EDT 2008


    [ http://opensource.atlassian.com/projects/hibernate/browse/HBX-1054?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_29911 ] 

Darryl Miles commented on HBX-1054:
-----------------------------------

Just because its the principal package owner (as my limited understanding understands it).  The package being org.hibernate.mapping.

The context was during the building of an "EntityManagerFactory" but I believe this situation to be generic enough to cover any factory building (i.e. also SessionFactory without use of EntityManager / JPA).

Sure the tooling XSD helped me fix the problem (once I found out which hbm.xml file had the problem, to track down the HBM took 15 minutes and all I needed in my case was a column name from the debugger as a clue).   The error was detected at runtime and a validating XML parser was not being used.  I believe there is enough information in the available data in that class to be able to emit something more useful.  The members "table" and "columns" would looks helpful enough to home in on the issue, if you could get to the HBM class we are working on that would be ideal.

Maybe from a higher level when SimpleValue objects are instated but typeName has not been able to be resolved then a better contextual warning might appear, but I could not know if there are valid use cases where typeName should be null.

Surely either of these methods would put changes into HBX.

> "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.CR1/core/src/main/java/org/hibernate/mapping/SimpleValue.java?r=11588#l258
> 	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.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list