您的位置:首页 > 移动开发 > Objective-C

a different object with the same identifier value was already associated with the session

2009-06-03 10:57 441 查看
a different object with the same identifier value was already associated with the session

出现异常的代码:

session.beginTransaction();   //开启事务

String hql="from MessageForm m where m.msg_id='"+msg_id+"'";
list=session.createQuery(hql).list();
MessageForm myform=(MessageForm)list.get(0);
myform.setMsg_back(msgform.getMsg_back());
myform.setMsg_back_time(msgform.getMsg_back_time());

session.update(myform);

session.getTransaction().commit();   //提交事务


修改后没问题的代码:

session.beginTransaction();   //开启事务

String hql="from MessageForm m where m.msg_id='"+msg_id+"'";
list=session.createQuery(hql).list();
MessageForm myform=(MessageForm)list.get(0);
myform.setMsg_back(msgform.getMsg_back());
myform.setMsg_back_time(msgform.getMsg_back_time());

session.update(myform);
session.save(myform);

session.getTransaction().commit();   //提交事务


参见:http://guoxubo.javaeye.com/blog/363019
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐