[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2034?page=c...
]
Galen Palmer commented on HHH-2034:
-----------------------------------
The specific problem is unrelated. I somehow was getting an integer value into the
StringType when mapping a set of tomcat user roles (as Strings) to a User entity class.
<set name="roles" table="user_roles"
lazy="false">
<key column="login" property-ref="identifier"/>
<element column="role" type="string" />
</set>
This appears to be happening in the session.update(user) call.
Anyway, when trying to track down the cause of this problem, I realized I was getting a
ClassCastException thrown from within the catch block of NullableType.
The toString(Object value) method of StringType simply does a (String)value cast which
caused the exception.
Another, alternate, fix would be to have StringType.toString(Object value) return somthing
like:
return value == null ? null : value.toString();
Potential ClassCastException in catch block in NullableType
-----------------------------------------------------------
Key: HHH-2034
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2034
Project: Hibernate3
Type: Improvement
Components: core
Versions: 3.1.3
Environment: Hibernate 3.1.3
Reporter: Galen Palmer
Priority: Minor
Original Estimate: 1 hour
Remaining: 1 hour
It is possible to throw an exception from within the catch block of
NullableType.nullSafeSet() since the toString(value) method calls in many cases (e.g.
StringType) simply result in a cast of return (String)value. This may mask the underlying
problem for the users.
A proposed solution would be to replace the call in the catch blog of toString(value)
with a reference to value. For example:
line 87:
log().info( "could not bind value '" + value + "' to parameter:
" + index + "; " + re.getMessage() );
and line 91:
log().info( "could not bind value '" + value + "' to parameter:
" + index + "; " + se.getMessage() );
This change would prevent the catch block from throwing the exception.
--
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