Hi folks,
I'm using Hibernate 3.2.0.CR1 with annotations and I get the exception
Code:
java.lang.ClassCastException
Stack Trace:
* org.hibernate.type.TimestampType.toString(TimestampType.java:55)
* org.hibernate.type.NullableType.nullSafeSet(NullableType.java:87)
* org.hibernate.type.NullableType.nullSafeSet(NullableType.java:65)
* org.hibernate.loader.Loader.bindPositionalParameters(Loader.java:1514)
* org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1576)
* org.hibernate.loader.Loader.doQuery(Loader.java:661)
* org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
* org.hibernate.loader.Loader.doList(Loader.java:2145)
* org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
* org.hibernate.loader.Loader.list(Loader.java:2024)
* org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:95)
* org.hibernate.impl.SessionImpl.list(SessionImpl.java:1536)
* org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
[...]
when trying to execute the following code:
Code:
[...]
Criteria criteria;
if (criteriaMap.containsKey("personId")
|| criteriaMap.containsKey("gender")
|| criteriaMap.containsKey("date"))
{
Integer personId = null;
Integer gender = null;
String date = null;
if (criteriaMap.containsKey("personId"))
{
personId = (Integer) criteriaMap.get("personId");
criteriaMap.remove("personId");
}
if (criteriaMap.containsKey("gender"))
{
gender = (Integer) criteriaMap.get("gender");
criteriaMap.remove("gender");
}
if (criteriaMap.containsKey("date"))
{
date = new SimpleDateFormat("yyyy-MM-dd").format(criteriaMap
.get("date"));
criteriaMap.remove("date");
}
criteria = getSession().createCriteria(Finding.class).add(
Restrictions.allEq(criteriaMap));
if (date != null)
criteria.add(Restrictions.like("date", date, MatchMode.START));
if (personId != null)
criteria.createCriteria("finder").add(
Restrictions.eq("id", personId));
[...]
Is this a bug or am I doing something wrong?