Posted on 2010-01-13 23:33
斷點 閱讀(1360)
評論(0) 編輯 收藏 所屬分類:
Hibernate
在做項目中碰見這樣的問題,如下:
Caused by: org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.pcis.cus.vo.CusClientVO#002255207];
原因: 有一個具有相同值的不同對象已經與和 session 相關聯。
解決(程序的一部分):
//CusClientVO cusVo = new CusClientVO();
CusClientVO cusVo = null;
IUserDetails user = CurrentUser.getUser();
try {
if ("Same".equals(cusFlag)) {//被保險人和投保人是同一人
cusVo = (CusClientVO)this.getById(CusClientVO.class, applicant.getCAppCde());
if(cusVo==null){ //表示新增客戶。
cusVo = new CusClientVO();
}
this.saveCusApplicant(applicant, cusVo);
if(!applicantflag ){
cusVo.setTCrtTm(new Date());
cusVo.setCCrtCde(user.getOpRelCde());
}
}
cusVo.setTUpdTm(new Date());
cusVo.setCUpdCde(user.getOpRelCde());
//
this.saveOrUpdate(cusVo);
} catch (DaoException ex) {
BusinessServiceException e = new BusinessServiceException(ex);
e.setErrorMsg("保存客戶信息失敗");
}
相關連接:
http://hi.baidu.com/anypcao/blog/item/0db1a41cd3478d8187d6b6d2.html
http://agreal.javaeye.com/blog/339560
posted @ 2009-10-31 13:11 斷點 閱讀(61) | 評論 (0)