1

I'm using a native query for updating a value of a certain key in a HashMap annotated with @ElementCollection.

After the query is executed the complete entity that contains the HashMap will be retrivied with EntityManager.find(...). The problem is, the HashMap in the retrieved entity still contains the old value.

How can I get the entity with the updated HashMap? Is it necessary to refresh the cache? I'm using Eclipse Link.

user1056903
  • 921
  • 9
  • 26

1 Answers1

2

I assume you have caching enabled (the default). So you will need to call refresh() to refresh the object.

Otherwise you could disable the shared cache, but if you do it in the context of an EntityManager the persistence context will still need to be refreshed or cleared to see the change.

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

James
  • 17,965
  • 11
  • 91
  • 146