org.hibernate.PersistentObjectException: detached entity passed to persist exception

前端 未结 4 1840
遇见更好的自我
遇见更好的自我 2021-02-13 01:23

I\'m creating a simple app to just insert a row to a table (if table does not exist, create it) using Java JPA.

I\'m attaching some code for a runnable exam

4条回答
  •  旧巷少年郎
    2021-02-13 02:24

    In the class definition you have annotated id to be generated by strategy (table, sequence, etc.) chosen by the persistence provider, but you are initializing the id of the Person object through constructor. I think leaving id null may solve your problem.

提交回复
热议问题