Incomplete MappingException at org.hibernate.mapping.SimpleValue

Description

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

Environment

None

Activity

Show:
Max Rydahl Andersen
September 4, 2006, 9:48 PM

could you provide it as a patch?

Barney Boisvert
September 8, 2006, 8:36 PM

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

Steve Ebersole
March 21, 2011, 7:06 PM

Bulk closing stale resolved issues

Assignee

Diego Plentz

Reporter

Diego Plentz

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

Priority

Major
Configure