EntityManager refresh

前端 未结 6 892
生来不讨喜
生来不讨喜 2020-12-08 10:05

I have web application using JPA. This entity manager keeps bunch of entites and suddenly I update the database from other side. I use MySQL and I use

6条回答
  •  离开以前
    2020-12-08 11:01

    entityManager.getEntityManagerFactory().getCache().evictAll()
    

    Refresh is something different since it modifies your object. This line will just empty the cache, so if you fetch objects changed outside the entity manager, it will do an actual database query instead of using the outdated cached value.

提交回复
热议问题