This is DetachedCriteria#getExecutableCriteria(Session) method's impl:
Code:
/**
* Get an executable instance of <literal>Criteria</literal>,
* to actually run the query.
*/
public Criteria getExecutableCriteria(Session session) {
impl.setSession( (SessionImpl) session );
return impl;
}
Why write " (SessionImpl) session " ? When I use Spring's
Code:
org.springframework.orm.hibernate3.HibernateCallback
It occurs a ClassCastException
My Code :
Code:
return getHibernateTemplate().executeFind(new HibernateCallback() {
public Object doInHibernate(Session session) throws HibernateException, SQLException {
DetachedCriteria detachedCriteria = HibernateUtil.getLikeDetachedCriteriaFromBean(user, order, HibernateConstants.DEFAULT_MATCH_MODE);
return HibernateUtil.getPageResult(detachedCriteria.getExecutableCriteria(session), begin, interval);
}
});
because in the doInHibernate method, the session is a Proxy object