spring-framework-3.2.4與hibernate-release-4.3.5下使用HibernateDaoSupport拋出異常

來源:互聯網
上載者:User

 spring-framework-3.2.4與hibernate-release-4.3.5下使用HibernateDaoSupport拋出異常java.lang.ClassCastException: org.springframework.orm.hibernate4.SessionHolder cannot be cast to org.springframework.orm.hibernate3.SessionHolder。



解決方式:



LZ開啟spring的jar包後,發現org.springframework.orm.hibernate4.support中沒有HibernateDaoSupport類,即用了hibernate4之後,不能再用HibernateDaoSupport和HibernateTemplate類了。
改用原生的hibernate語句獲得session:getSessionFactory().getCurrentSession()。


註:LZ是新手,只為交流,如有不當之處,請指出。即使,扔板磚也可以。

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.