EntityManager persist() method does not insert record to database

前端 未结 9 963
没有蜡笔的小新
没有蜡笔的小新 2021-02-04 11:52

I have problem with using EntityManager.persist(Object) method. Now when i get rid of other problems, by app work without Exception but object is not put in my data

9条回答
  •  名媛妹妹
    2021-02-04 12:39

    Try this:

    em.getTransaction().begin();
    em.persist(entity);
    em.getTransaction().commit();
    

    PS: You should set a generation method for your ID as well.

提交回复
热议问题