hivemind-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alan Chaney <>
Subject Hivemind creates proxy Hibernate Session
Date Wed, 04 Apr 2007 21:27:03 GMT

I've based my Hivemind/Hibernate code on James Carman's excellent 
example. I am using this in a new project in preference to the Spring 
Hibernate framework because its simpler and easier to understand IMHO. 
However, I've hit one slight snag. In part of my code I use a Hibernate 
DetachedCriteria object which gets associated with a session by a 
Hibernate call such as
DetachedCriteria dc = DetachedCriteria.forClass(MyClass.class);

(and then, much later inside the DAO)

Criteria cc = dc.getExecutableCriteria(Session session);

where session has been injected by Hivemind. However, it seems that 
Hivemind injects a proxy and getExecutableCriteria casts to a 
SessionImplementor and cannot cast the Hivemind created proxy giving me:

java.lang.ClassCastException: $Session_111be7b3773

Is there any way to obtain the 'real' Session object from the proxy? Or 
can anyone suggest another way to solve this problem. I looked at the 
Spring equivalent which uses a special method within the Spring 
HibernateTemplate class but I got lost trying to understand how the 
HibernateCallback overcame this problem.


Alan Chaney

View raw message