Hibernate 2nd level cache invalidation when another process modifies the database

前端 未结 6 1124
[愿得一人]
[愿得一人] 2020-12-07 19:16

We have an application that uses Hibernate\'s 2nd level caching to avoid database hits.

I was wondering if there is some easy way to invalidate the Java application

6条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-07 19:37

    Both hibernate and JPA now provide direct access to the underlying 2nd level cache:

    sessionFactory.getCache().evict(..);
    entityManager.getCache().evict(..)
    

提交回复
热议问题