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

前端 未结 4 1720
遇见更好的自我
遇见更好的自我 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:08

    You can use this contrustor like this:

    Person p = new Person(0, "Peter", "Parker");
    

    then when JPA persist to database it'll automatically insert with AUTO_INCREMENT strategy.

提交回复
热议问题