onsdag 7 januari 2009

JPA Query cache

Ok i'll take this one in english since it doesn't touch any motorcycle stuff :)

I've recently had some cacheing problem with JPA when working with detached entities that we later on had to re-attache due to the fact that we are using EJB and hence have 2 separated domains.

In our case we actually don't want any cacheing under many circumstances since this put alot of old information into the entitymanager that is later fetched by other threads and hence they get old information. However it seems like many entitymanger providers have cacheing turned on by default.

I found an interesting blog article java.net which explains this problem pretty well, http://weblogs.java.net/blog/guruwons/archive/2006/09/understanding_t.html . This one is for those of you who are using toplink essentials, if you insted are using Kodo (BEA/ORACLE) as we do, please take a peek at http://edocs.bea.com/kodo/docs40/full/html/ref_guide_caching.html for more info on how to turn of the cache.

This seems to work very well but unfortunely you turn of ALL cacheing using this one, maybe not a wanted behaviour.

JPA XML Style:

>property name="kodo.QueryCache" value="false"/<

Inga kommentarer: