【发布时间】:2014-04-12 13:33:45
【问题描述】:
这是我对 Spring Bean 的配置:
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
然后我像这样在 DAO 层中使用它:
@Resource(name = "sessionFactory")
private SessionFactory sessionFactory;
我的问题终于来了:
public T getById(int id) {
Session session = sessionFactory.getCurrentSession();
return (T) session.get(clz, id);
}
总之,我的问题是:
在"org.springframework.orm.hibernate4.LocalSessionFactoryBean"类中,没有SessionFactory's方法的实现——“getCurrentSessio”。
我跟踪LocalSessionFactoryBean's层次系统,但我没有找到方法“getCurrentSession”的实现。
期待您的回答,非常感谢!
【问题讨论】:
标签: spring hibernate session code-injection