Spring4整合Hibernate3的简单测试
[size=12px]业务逻辑代码中加入写入这行代码:
public void createPerson(PersonBean p) throws Exception
{
this.getSessionFactory().getCurrentSession().save(p);
}
会报错:No Session found for current thread.
而改成:this.getSessionFactory().openSession().save(p);则主程序中的数据会插入成功.另外配置文件在出错前后都没有加入事务控制,我想知道改个方法为何会出现这种情况?谁能告诉我原理?