[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-6313?page=c...
]
Tom Jordahl commented on HHH-6313:
----------------------------------
I am also seeing this error after upgrading from Hibernate 3.5.3 to 3.6.6.
It causes a regression in our test suites.
Hibernate 3.6.6 Stack trace:
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Character
at
org.hibernate.type.descriptor.java.CharacterTypeDescriptor.unwrap(CharacterTypeDescriptor.java:34)
at
org.hibernate.type.descriptor.sql.VarcharTypeDescriptor$1.doBind(VarcharTypeDescriptor.java:52)
at org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:91)
at
org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:283)
at
org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:278)
at
org.hibernate.param.NamedParameterSpecification.bind(NamedParameterSpecification.java:67)
at org.hibernate.loader.hql.QueryLoader.bindParameterValues(QueryLoader.java:571)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1716)
at org.hibernate.loader.Loader.doQuery(Loader.java:801)
at
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
at org.hibernate.loader.Loader.doList(Loader.java:2533)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
at org.hibernate.loader.Loader.list(Loader.java:2271)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:452)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1268)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
I'll take a look at making a patch if I can. I am suspicious of the code in
VarcharTypeDescriptor.java:
public <X> ValueBinder<X> getBinder(final JavaTypeDescriptor<X>
javaTypeDescriptor) {
return new BasicBinder<X>( javaTypeDescriptor, this ) {
@Override
protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options)
throws SQLException {
st.setString( index, javaTypeDescriptor.unwrap( value, String.class, options ) );
}
};
}
It appears that is is trying to upwrap the character type as a string and this is what is
trigger the cast exception, but I need to dig in to to figure out why the templated
classes being used here are throwing the cast exception before any code (i.e. unwrap) is
getting called.
Developer eyes on this (Steve Ebersole?) would be very helpful as this is blocking our
upgrade to 3.6.
ClassCastException specifying type="character" in hbm.xml
---------------------------------------------------------
Key: HHH-6313
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-6313
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 3.6.0, 3.6.4, 3.6.5
Environment: Hibernate 3.6.5, Oracle 10g
Reporter: Martin
I have a class containing a field of type java.lang.Character.
I map this to an Oracle char(1 byte) field using an hmb.xml file as follows:
<property name="IntroducedFlag" column="INTRODUCED"
type="character" />
At runtime this results in the following exception:
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Character
at
org.hibernate.type.descriptor.java.CharacterTypeDescriptor.unwrap(CharacterTypeDescriptor.java:34)
at
org.hibernate.type.descriptor.sql.VarcharTypeDescriptor$1.doBind(VarcharTypeDescriptor.java:52)
at org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:91)
at
org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:282)
at
org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:277)
at org.hibernate.loader.Loader.bindPositionalParameters(Loader.java:1873)
at org.hibernate.loader.Loader.bindParameterValues(Loader.java:1844)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1716)
at org.hibernate.loader.Loader.doQuery(Loader.java:801)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
at org.hibernate.loader.Loader.doList(Loader.java:2533)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
at org.hibernate.loader.Loader.list(Loader.java:2271)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:119)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1716)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:347)
It works fine in Hibernate 3.5.6 but not in 3.6.0 onwards.
Also probably related to this issue:
https://forum.hibernate.org/viewtopic.php?f=1&t=1010175
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira