Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Disable eclipselink caching and query caching - not working?
Disable eclipselink caching and query caching - not working? [message #536283] Thu, 27 May 2010 14:37 Go to next message
James Gralton is currently offline James GraltonFriend
Messages: 2
Registered: May 2010
Junior Member
I am using eclipselink JPA with a database which is also being updated externally to my application. For that reason there are tables I want to query every few seconds. I can't get this to work even when I try to disable the cache and query cache. For example:

EntityManagerFactory entityManagerFactory =  Persistence.createEntityManagerFactory("default");
EntityManager em = entityManagerFactory.createEntityManager();

MyLocation one = em.createNamedQuery("MyLocation.findMyLoc").getResultList().get(0);

Thread.sleep(10000);

MyLocation two = em.createNamedQuery("MyLocation.findMyLoc").getResultList().get(0);  

System.out.println(one.getCapacity() + " - " + two.getCapacity());

Even though the capacity changes while my application is sleeping the println always prints the same value for one and two.

I have added the following to the persistence.xml

<property name="eclipselink.cache.shared.default" value="false"/>
<property name="eclipselink.query-results-cache" value="false"/>


I must be missing something but am running out of ideas.

James
Re: Disable eclipselink caching and query caching - not working? [message #536932 is a reply to message #536283] Mon, 31 May 2010 14:35 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1039
Registered: July 2009
Senior Member
Hello,

I believe Tom responded to you in the EclipseLink user forum at:
http://old.nabble.com/Re%3A-Force-query-to-db-and-not-use-ca che-p28730236.html

Basically, the settings used so far are turning off the upfront cache check. Because you are reading through an entitymanger though, you must get back managed entities based on the object identity. So even if the query hits the database, the row returned is used to check the L1 cache and return the managed entity. You will need to force it to refresh to have the managed entity rebuilt using the returned row.

Best Regards,
Chris
Previous Topic:Problem with DescriptorEventAdapter and EJBContext
Next Topic:Eclipselink 1.1.3 choosing the wrong table id generator
Goto Forum:
  


Current Time: Fri Nov 28 11:07:31 GMT 2014

Powered by FUDForum. Page generated in 0.01932 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software