EntityManager refresh

前端 未结 6 949
生来不讨喜
生来不讨喜 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:04

    I had a similar issue and the evictAll() line above worked for me.

    Alternatively, the @Cache annotation on the entity class worked too, with the benefit of being able to control caching parameters:

    @Cache(coordinationType=CacheCoordinationType.INVALIDATE_CHANGED_OBJECTS)
    

    See: http://wiki.eclipse.org/EclipseLink/Examples/JPA/Caching

提交回复
热议问题