Hi,
I work with Hibernate 3.6.0.Final an I have the same problem as described below.
Is the bug still alive?
According to
http://opensource.atlassian.com/project ... se/HHH-957, a patch has been published in a previous version.
Code:
DetachedCriteria dc = DetachedCriteria.forClass(MySubObject.class);
Disjunction or = Restrictions.disjunction();
...
or.add(
Property.forName("id").in(dc)
);
works fine whereas :
Code:
DetachedCriteria dc = DetachedCriteria.forClass(MySubObject.class);
Disjunction or = Restrictions.disjunction();
...
or.add(
Subqueries.in("id", dc)
);
doesn't work!
Does somebody has any idea?
Thanks!
Letskank
Here is the stacktrace :
Code:
Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
at org.hibernate.type.descriptor.java.IntegerTypeDescriptor.unwrap(IntegerTypeDescriptor.java:36)
at org.hibernate.type.descriptor.sql.IntegerTypeDescriptor$1.doBind(IntegerTypeDescriptor.java:52)
at org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:89)
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)
... 17 more
Hibernate log :
Code:
6766 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - preparing statement
6797 [main] DEBUG fcdq.grrope.rocr.modele.util.hibernate.UserTypeInteger - binding parameter [2] as [INTEGER] - 1
6797 [main] DEBUG org.hibernate.type.descriptor.sql.BasicBinder - binding parameter [3] as [INTEGER] - id
In the log, we can see that Hibernate is binding parameter "3" as an Integer instead of a String.