zoukankan      html  css  js  c++  java
  • s2sh保存错误: a different object with the same identifier value was already associated


    org.springframework.orm.hibernate3.HibernateSystemException:
              a different object with the same identifier value was already associated with the session: [com.demo.bean.Option]

    因为在hibernate中同一个session里面有了两个相 同标识但是是不同实体,当这时运行saveOrUpdate(object)操作的时候就会报这个错误。解决方法是:
    hibernate3.0以上使用merge()来合并两个session中的同一对象:
    public void attachDirty(Role instance) {
            log.debug("attaching dirty Role instance");
            try {
               instance = hibernateTemplate.merge(instance);
                hibernateTemplate.saveOrUpdate(instance);
                log.debug("attach successful");
            } catch (RuntimeException re) {
                log.error("attach failed", re);
                throw re;
            }
        }

  • 相关阅读:
    double相加(減)结果会有些误差
    创建表,操作表
    删除数据库
    DDL语句
    HCDA-12-配置基本静态路由
    HCDA-11-配置直连路由
    1-5配置STelnet登录系统
    HCDA-9-管理设备文件系统
    HCDA-8-了解设备系统文件
    Java生成随机汉字
  • 原文地址:https://www.cnblogs.com/summer520/p/2964263.html
Copyright © 2011-2022 走看看