คำถามติดแท็ก persist


18
PersistentObjectException: เอนทิตีที่แยกออกมาถูกส่งผ่านเพื่อคงอยู่โดย JPA และ Hibernate
ฉันมีรูปแบบวัตถุ JPA-ยืนกรานที่มีหลายต่อหนึ่งความสัมพันธ์: การมีจำนวนมากAccount มีหนึ่งTransactionsTransactionAccount นี่คือตัวอย่างของรหัส: @Entity public class Transaction { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; @ManyToOne(cascade = {CascadeType.ALL},fetch= FetchType.EAGER) private Account fromAccount; .... @Entity public class Account { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; @OneToMany(cascade = {CascadeType.ALL},fetch= FetchType.EAGER, mappedBy = "fromAccount") private Set<Transaction> transactions; ฉันสามารถสร้างAccountวัตถุเพิ่มธุรกรรมไปยังAccountวัตถุนั้นและคงวัตถุไว้อย่างถูกต้อง แต่เมื่อฉันสร้างธุรกรรมโดยใช้บัญชีที่มีอยู่แล้วและยืนยันการทำธุรกรรมฉันจะได้รับข้อยกเว้น: เกิดจาก: …
237 java  hibernate  jpa  entity  persist 
โดยการใช้ไซต์ของเรา หมายความว่าคุณได้อ่านและทำความเข้าใจนโยบายคุกกี้และนโยบายความเป็นส่วนตัวของเราแล้ว
Licensed under cc by-sa 3.0 with attribution required.