[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2048) Incomplete MappingException at org.hibernate.mapping.SimpleValue

Barney Boisvert (JIRA) noreply at atlassian.com
Fri Sep 8 14:38:24 EDT 2006


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2048?page=comments#action_24393 ] 

Barney Boisvert commented on HHH-2048:
--------------------------------------

Here's a patch.  Enormously easier to debug erroneous mappings with this little addition

Index: /home/barneyb/workspaces/audiencecentral/Swordfish/src/org/hibernate/mapping/SimpleValue.java
===================================================================
--- /home/barneyb/workspaces/audiencecentral/Swordfish/src/org/hibernate/mapping/SimpleValue.java	(revision 250)
+++ /home/barneyb/workspaces/audiencecentral/Swordfish/src/org/hibernate/mapping/SimpleValue.java	(working copy)
@@ -260,6 +260,9 @@
         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;
             }


> Incomplete MappingException at org.hibernate.mapping.SimpleValue
> ----------------------------------------------------------------
>
>          Key: HHH-2048
>          URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2048
>      Project: Hibernate3
>         Type: Improvement

>     Versions: 3.2.0.cr4
>     Reporter: Diego Pires Plentz

>
>
> When a mapped class has a wrong type, an exception is throwed, but it doesnt say nothing about what class/table is mapped wrongly.
> 	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(columns!=null && columns.size()>0) {
> 				msg += ", for columns: " + columns;
> 			}
> 			throw new MappingException(msg);
> 		}
> 		return result;
> 	}
> Can become something like this... 
> 	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;
> 	}

-- 
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