Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » How to clear cache?(JPA 2.0 clear cache)
How to clear cache? [message #1008461] Tue, 12 February 2013 15:24 Go to next message
Andrea Tasca is currently offline Andrea Tasca
Messages: 2
Registered: February 2013
Junior Member
Hi,
I need to clear cache on Eclipselink JPA 2.0.
As from documentation http://wiki.eclipse.org/EclipseLink/Examples/JPA/Caching
this can be done using the JPA Cache interface:
em.getEntityManagerFactory().getCache().evictAll();
but "the method getEntityManagerFactory() is undefined for the type EntityManager".
This is my code:

EntityManagerFactory factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
EntityManager em = factory.createEntityManager();
em.getEntityManagerFactory().getCache().evictAll();

What am I doing wrong?

Thank you.
Re: How to clear cache? [message #1008700 is a reply to message #1008461] Wed, 13 February 2013 16:02 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris Delahunt
Messages: 1034
Registered: July 2009
Senior Member
getEntityManagerFactory() exists on javax.persistence.EntityManager since JPA 2.0, so it means you are using a JPA 1.0 jar. Check your classpath and verify you have javax.persistence_2.0.3.v201010191057.jar (shipped with EclipseLink 2.3.2) ahead of or instead of the javax.persistence_1.0.0.jar.
Re: How to clear cache? [message #1009101 is a reply to message #1008700] Thu, 14 February 2013 12:40 Go to previous message
Andrea Tasca is currently offline Andrea Tasca
Messages: 2
Registered: February 2013
Junior Member
Hi Chris you are right.
I had either javax.persistence_1.0.0.jar and javax.persistence_2.0.4.v201112161009.jar
in my classpath.
I've removed javax.persistence_1.0.0.jar and now it works.

Thank you.
Previous Topic:Simple Auditing Example
Next Topic:ClassCastException when trying to access OneToOne object
Goto Forum:
  


Current Time: Sat Oct 25 19:42:01 GMT 2014

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

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