org.hibernate.PersistentObjectException: detached entity passed to persist

后端 未结 7 1414
生来不讨喜
生来不讨喜 2020-11-30 00:56

I had successfully written my first master child example with hibernate. After few days I took it again and upgraded some libraries. No sure what did I do but I could never

7条回答
  •  我在风中等你
    2020-11-30 01:33

    You didn't provide many relevant details so I will guess that you called getInvoice and then you used result object to set some values and call save with assumption that your object changes will be saved.

    However, persist operation is intended for brand new transient objects and it fails if id is already assigned. In your case you probably want to call saveOrUpdate instead of persist.

    You can find some discussion and references here "detached entity passed to persist error" with JPA/EJB code

提交回复
热议问题