您的位置:首页 > 其它

org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not a

2012-12-16 23:08 375 查看


org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation
of non-transactional one here

错误重现:

public class BaseDaoImpl<T,PK extends Serializable> extends HibernateDaoSupport implements IBaseDao<T,PK>{

private Session getCurrentSession() {

return this.getHibernateTemplate().getSessionFactory().getCurrentSession();

}

public Serializable save(T o) {

return this.getCurrentSession().save(o);

}
}

调用save时 报错。

解决方案:
return this.getCurrentSession().save(o); 改成
return this.getHibernateTemplate().save(o);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐