zoukankan      html  css  js  c++  java
  • Hibernate常见的错误异常

    1.错误:object references an unsaved transient instance - save the transient instance before flushing:

    com.xxxx.bean.java.Sysblog; nested exception is org.hibernate.TransientObjectException: object references an unsaved

    transient instance - save the transient instance before flushing: com.xxx.bean.java.Sysblog

    解决方法:没有可预期的实例,当然就要实例化对象

    2.错误:Exceptionobject references an unsaved transient instance - save the transient instance before flushing:

    src.persistent.Product......

    解决方法:原因没有为某对象进行set设置, 如上边的这个就是某对象没有调用setProduct

    3.错误:Illegal attempt to associate a collection with two open sessions......

    解决方法:(hibernatesession提供了一级缓存,每个session,对同一个id进行两次load,不会发送两条sql给数据库,但是session关闭的

    时候,一级缓存就失效了。

    sysblogarticle.setAmount(new Long(sysblogcommentService.selcom(
                      sysblogarticle.getArticleid().toString()).size()));//通过文章id获取文章评论数
               sysblogarticle.setSysblogcomments(null);//关键
               sysblogarticleService.saveOrUpdate(sysblogarticle);//将文章中评论条数修改

  • 相关阅读:
    三级菜单python写法(递归写法)
    webstorm2018.1.6版本安装+破解+汉化
    sourceTree 的使用教程
    nodeppt的使用教程
    堆和栈的区别(转过无数次的文章)
    黎曼滤波在神经计算方面的应用
    深度学习笔记——PCA原理与数学推倒详解
    TCP/IP模型详解
    OSI7层模型详解
    CNN车型分类总结
  • 原文地址:https://www.cnblogs.com/jingxiaopu/p/9310428.html
Copyright © 2011-2022 走看看