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 @ 2024-10-24 11:37  奇异宝  阅读(16)  评论(0编辑  收藏  举报