PersistentObjectException: detached entity passed to persist thrown by JPA and Hibernate

前端 未结 18 2632
醉酒成梦
醉酒成梦 2020-11-22 05:10

I have a JPA-persisted object model that contains a many-to-one relationship: an Account has many Transactions. A Transaction has one

18条回答
  •  余生分开走
    2020-11-22 05:39

    The solution is simple, just use the CascadeType.MERGE instead of CascadeType.PERSIST or CascadeType.ALL.

    I have had the same problem and CascadeType.MERGE has worked for me.

    I hope you are sorted.

提交回复
热议问题