-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: DetachedCriteria's bug?
PostPosted: Mon Jun 20, 2005 4:46 am 
Newbie

Joined: Mon Jun 20, 2005 4:32 am
Posts: 4
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


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 20, 2005 12:35 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
http://www.hibernate.org/ForumMailingli ... AskForHelp


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 21, 2005 4:53 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Simply set 'exposeNativeSession' to true in HibernateTemplate.
Or do you loose something important from Spring's proxy?

But I agree that it is funny that DetachedCriteria depends on an actual implementation - SessionImpl, since all Hibernate's code is elegantly written to interfaces.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.