首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > PowerDesigner >

hibernate update 异常解决

2012-11-18 
hibernate update 错误解决update时候出现如下错误org.hibernate.NonUniqueObjectException: a different

hibernate update 错误解决
update时候出现如下错误
org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session:
解决方法:
根据id得到缓存里的pojo对象,修改该对象,更新该对象

public void update(AppInfo appInfo){AppInfo ai = getAIById(appInfo.getId());ai.setAct(appInfo.getAct());ai.setApp_name(appInfo.getApp_name());ai.setApp_id(appInfo.getApp_id());ai.setInstall_ram_range(appInfo.getInstall_ram_range());ai.setPackage_name(appInfo.getPackage_name());ai.setSwitch_ram_range(appInfo.getSwitch_ram_range());Transaction ts = s.beginTransaction();s.update(ai);ts.commit();}

热点排行