EntityManager persist() method does not insert record to database

前端 未结 9 938
没有蜡笔的小新
没有蜡笔的小新 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:48

    Are you getting a specific exception? It would be helpful to know what it is if you are.

    There are a number of similar problems to this already on Stackoverflow:

    Spring transactional context doesn't persist data

    Spring, Hibernate & JPA: Calling persist on entitymanager does not seem to commit to database

    These suggest that you should try adding em.flush() after the em.persist(chain), and altering the @transactional annotations

    You should also check that you have enabled transactional annotations through a line such as :

     
    

    in your .xml configuration

提交回复
热议问题