org.hibernate.NonUniqueObjectException: a different object with the same identifier value was alread
2012-08-04 15:38
585 查看
Session session = HibernateSessionFactory.getSession();
Transaction tx = null;
try {
tx = session.beginTransaction();
tx.begin();// 保持数据原子性,出错了可以回滚,但是呢,资源暂用很多哦
u_send.setIdealMoney(u_send.getIdealMoney() - money);
u_rec.setIdealMoney(u_rec.getIdealMoney() + money);
session.saveOrUpdate(u_send);
//session.merge(u_rec);
session.saveOrUpdate(u_rec);
tx.commit();
} catch (Exception e) {
e.printStackTrace();
if (tx != null) {
tx.rollback();
}
return "出现异常:" + e.toString();
} finally {
session.close();
}
红色部分是问题出现的地方。。。吧红色部分改成
session.saveOrUpdate(u_send);
session.merge(u_rec);
就ok
Transaction tx = null;
try {
tx = session.beginTransaction();
tx.begin();// 保持数据原子性,出错了可以回滚,但是呢,资源暂用很多哦
u_send.setIdealMoney(u_send.getIdealMoney() - money);
u_rec.setIdealMoney(u_rec.getIdealMoney() + money);
session.saveOrUpdate(u_send);
//session.merge(u_rec);
session.saveOrUpdate(u_rec);
tx.commit();
} catch (Exception e) {
e.printStackTrace();
if (tx != null) {
tx.rollback();
}
return "出现异常:" + e.toString();
} finally {
session.close();
}
红色部分是问题出现的地方。。。吧红色部分改成
session.saveOrUpdate(u_send);
session.merge(u_rec);
就ok
相关文章推荐
- org.hibernate.NonUniqueObjectException: a different object with the same identifier value was alread
- org.hibernate.NonUniqueObjectException: a different object with the same identifier value was alread---------程序报错
- org.hibernate.NonUniqueObjectException: A different object with the same identifier value was alread
- org.hibernate.NonUniqueObjectException: A different object with the same identifier value was alread
- org.hibernate.NonUniqueObjectException: a different object with the same identifier value was alread
- org.hibernate.NonUniqueObjectException: A different object with the same identifier value was alread
- org.hibernate.NonUniqueObjectException:a different object with the same identifier value was alread
- org.hibernate.NonUniqueObjectException: A different object with the same identifier value was alread
- org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the sessio
- org.hibernate.NonUniqueObjectException: a different object with the same identifier value was ...
- org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the sessio
- org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the sessio
- org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the sessio
- org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the sessio
- org.hibernate.NonUniqueObjectException: A different object with the same identifier解决方法
- hibernate错误:org.hibernate.NonUniqueObjectException: a different object with the same identifier valu
- 报错信息:Caused by: org.hibernate.NonUniqueObjectException: a different object with the same identifier
- org.springframework.dao.DuplicateKeyException: a different object with the same identifier value was
- org.hibernate.NonUniqueObjectException: a different object with the same ide
- org.hibernate.NonUniqueObjectException: a different object with the same ide