Hi there,
I'm getting a mysterious ClassCastException when I run my java code as JUnitTestCase. I'm getting following exception, when I try to call criteria.uniqueResult() in some situations - but there seems to be no regularity for this appearance. Difficult.... I know... :(
Exception Stack:
Code:
java.lang.ClassCastException: org.hibernate.util.MarkerObject
at org.hibernate.engine.StatefulPersistenceContext.getCachedDatabaseSnapshot(StatefulPersistenceContext.java:277)
at org.hibernate.event.def.DefaultFlushEntityEventListener.getDatabaseSnapshot(DefaultFlushEntityEventListener.java:511)
at org.hibernate.event.def.DefaultFlushEntityEventListener.dirtyCheck(DefaultFlushEntityEventListener.java:472)
at org.hibernate.event.def.DefaultFlushEntityEventListener.isUpdateNecessary(DefaultFlushEntityEventListener.java:190)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:113)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:195)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:35)
at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:954)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1526)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
at org.hibernate.impl.CriteriaImpl.uniqueResult(CriteriaImpl.java:305)
at easy.util.SessionInfo.findByCriteriaUniqueResult(SessionInfo.java:290)
....
Class easy.util.SessionInfo:
Code:
...
286 public static <T extends PersistentObject> T findByCriteriaUniqueResult(Class<T> clazz, Criterion criterion) {
287 Criteria criteria = currentHibernateSession(clazz).createCriteria(clazz);
288 if (criterion != null)
289 criteria.add(criterion);
290 return (T) criteria.uniqueResult();
291 }
...
Hibernate version:
Hibernate 3.1.3
Hibernate Annotations 3.1.0 beta10
I've tried Google and ForumSearch as usual but with no result this time.
Thanks in advance for any help! If more information is needed, please let me know...
GreenTurtle