Thursday, October 30, 2008

JPA and EntityManager

Here's a doozy that I haven't come across yet....
Using JPA. Everything works great when going straight through the JPA application. Data gets retrieved and saved just fine.
If the data is changed in the database by some backend process (or just amnually throught some SQL tool), the JPA application does not refresh the data. It appears to be pulling it from a cache.

I found this great article
http://weblogs.java.net/blog/guruwons/archive/2006/09/understanding_t_1.html

amd info on TopLink JPA Caching
http://www.oracle.com/technology/products/ias/toplink/jpa/resources/toplink-jpa-extensions.html#TopLinkCaching

and.......it worked!!!! :)
added "q.setHint("toplink.refresh", "true");" (where q is Query) to those queries where data could be updated from other process.

No comments: