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

org.hibernate.TransientPropertyValueException: object references an unsaved transient instance - save the transient instance before flushing : com.jms.cfc.product.domain.ProductMaintainHistory.product -> com.One; nested exception is java.lang.IllegalStateException: org.hibernate.TransientPropertyValueException: object references an unsaved transient instance - save the transient instance before flushing : com.Many -> com.One

 

 

@Entity @Table(name = "employee") public class Employee { ... @ManyToOne @Cascade(CascadeType.SAVE_UPDATE) @JoinColumn(name = "department_id") private Department department; ... }

 

@Entity @Table(name = "department") public class Department { ... @OneToMany(mappedBy = "department", cascade = CascadeType.ALL, orphanRemoval = true) private Set<Employee> employees = new HashSet<>(); ... }

 

出处:--https://www.baeldung-cn.com/hibernate-unsaved-transient-instance-error

posted @   奇异宝  阅读(41)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
点击右上角即可分享
微信分享提示