错误原因:
在调用hibernate存储数据时,需要将数据库中表对应的持久类对象作为参数传递。如果这时的对象中有其他的表字段属性并且是引用对象类型,那么这个属性必须是持久态或者是null的,瞬时态和脱管态都会报错。我这次报错就是因为在订单对象中包含了其他对象,并且这些对象不为null。
如果包含的对象的数据用不到的话,最简便的解决办法就是把包含的对象全部置为null。
如果用得到对象中的数据,那么调用持久层的方法重新查询出对应的对象,此对象此时为持久态,在重新赋值到要保存的对象中即可。

原文链接:https://blog.csdn.net/sinat_39789638/article/details/78208481

jpa报错object references an unsaved transient instance的更多相关文章

  1. ManyToMany【项目随笔】关于异常object references an unsaved transient instance

    在保存ManyToMany  时出现异常: org.springframework.dao.InvalidDataAccessApiUsageException: org.hibernate.Tran ...

  2. ERROR org.hibernate.internal.SessionImpl - HHH000346: Error during managed flush [object references an unsaved transient instance - save the transient instance before flushing: cn.itcast.domain.Custom

    本片博文整理关于Hibernate中级联策略cascade和它导致的异常: Exception in thread "main" org.hibernate.TransientOb ...

  3. object references an unsaved transient instance save the transient instance before flushing

    object references an unsaved transient instance save the transient instance before flushing 对象引用未保存的 ...

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

    异常1:not-null property references a null or transient value解决方法:将“一对多”关系中的“一”方,not-null设置为false(参考资料: ...

  5. Hibernate的一个问题object references an unsaved transient instance - save the transi5

    1 我做了一对多和多对一的双向关联关系,在User这一方@ManyToOne已经设置了级联Cascade,这样在测试程序中保存User时,Group也应该自动保存,为什么会抛出以下的异常: (我是按着 ...

  6. object references an unsaved transient instance【异常】

    [异常提示] TransientObjectException: object references an unsaved transient instance -save the transient ...

  7. 三大框架常遇的错误:hibernate : object references an unsaved transient instance

    hibernate : object references an unsaved transient instance 该错误是操作顺序的问题,比如: save或update顺序问题---比方学生表和 ...

  8. object references an unsaved transient instance - save the transient instance before flushing: com.jspxcms.core.domain.ScTeam

    object references an unsaved transient instance - save the transient instance before flushing: com.j ...

  9. object references an unsaved transient instance - save the transient instance before flushing异常问题处理

    一.异常:org.hibernate.TransientObjectException: object references an unsaved transient instance - save ...

随机推荐

  1. window.location操作url对象

    URL即:统一资源定位符 (Uniform Resource Locator, URL) 完整的URL由这几个部分构成:scheme://host:port/path?query#fragment s ...

  2. JS水仙花数

    题目:3位数==个位立方+十位的立方+百位的立方.这个3位数就是水仙花数.要求打印出所有的水仙花数 <body> <div id=d1> </div> <sc ...

  3. Spark之RDD本质

    1.在一个完整的数据转换流程里往往涉及到多个具有衍生关系RDD,这些RDD其实是通过逻辑串联来利用装饰器模式层层包装扩展的的一堆对象,这些相邻RDD间必须有继承关系.并且比Java中的装饰器来的更彻底 ...

  4. 学习了解CSS3发展方向和CSS样式与优先级

    通过学习CSS3游戏介绍.CSS样式和优先级章节,了解到html5+css3+js不光可以实现动画,其次可以往这个游戏与建模方向发展,更多css3特效访问Gerard Ferrandez on Cod ...

  5. centos7使用fdisk:创建和维护MBR分区表

    1.在VMware选择要添加硬盘的虚拟机,添加一块硬盘. 这样就有两块硬盘 2.重启虚拟机. cd /dev #dev是设备目录,下面有很多很多设备,其中就包含硬盘 ll grep | sd #过滤s ...

  6. Linux btrfs文件系统

    btrfs,它名字挺多:B-tree fs;Butter fs;Better fs 开源协议是GPL,2007年由Oracle研发 核心特性: 多物理卷支持,btrfs可由多个物理卷组成:支持RAID ...

  7. CSGO控制台命令

    转帖: 按下“~”即可开启 使用时先输入参数名 然后按下SPACE空出一格 再输入设定值即可 一般玩家进入游戏都只能用到Client(玩家用参数) 不过...如果你是开LAN GAME的人 就能进阶到 ...

  8. Kubernetes 部署 Nebula 图数据库集群

    Kubernetes 是什么 Kubernetes 是一个开源的,用于管理云平台中多个主机上的容器化的应用,Kubernetes 的目标是让部署容器化的应用简单并且高效,Kubernetes 提供了应 ...

  9. kuangbin专题 专题九 连通图 Warm up HDU - 4612

    题目链接:https://vjudge.net/problem/HDU-4612 题目:一个大地图,给定若干个连通图,每个连通图中有若干个桥,你可以在任意某个连通图的 任意两个点添加一条边,问,添加一 ...

  10. es的分布式架构原理是什么?

    es的分布式架构原理是什么? 1.首先说一些分片(shard)是什么? ES中所有数据均衡的存储在集群中各个节点的分片中,会影响ES的性能.安全和稳定性 每个shard都是一个最小工作单元,承载部分数 ...