0%

hibernate异常org.hibernate.NonUniqueObjectException

异常报错:org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session:

出现原因:发生这种异常的原因是在执行修改操作的时候,session管理两个具有相同标识符的持久对象造成的

解决方法:使用this.getHibernateTemplate().getSessionFactory().getCurrentSession().clear();在进行第二次数据库操作之前,将hibernate中的缓存清除掉

欢迎关注我的其它发布渠道