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;
            }
        }

  • 相关阅读:
    Mysql-窗口函数
    aplly-lambda-map用法
    python-pymysql 操作数据库-创建-写入-多线程写入-读取-清空表
    graphviz安装
    sklearn-决策树
    pandas-烹饪指南
    Tomcat配置https
    azkaban 编译部署
    sqoop部署及使用
    spark面试题-1
  • 原文地址:https://www.cnblogs.com/summer520/p/2964263.html
Copyright © 2011-2022 走看看