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
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