0

I have application written in Java that is using EJB3 + Toplink. I'm using Glassfish as my app. server.

Sometimes the data that has been cached is old and I need to clear my cache manually. I know that we can set time to clear it, but I would like to make a button that will manually clear it for me. Is is possible to do?

Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
Maksim
  • 16,635
  • 27
  • 94
  • 135

2 Answers2

2

Apparently you can refresh cache with you query your database using this code:

Query query = em.createQuery(sql.toString()).setHint("toplink.refresh", "true");

This works for me.

Maksim
  • 16,635
  • 27
  • 94
  • 135
0

I think it is better to use:

em.createNamedQuery("findAll").setHint(QueryHints.CACHE_RETRIEVE_MODE, CacheRetrieveMode.BYPASS).getResultList();

it works for me and I think it is more standard way.

Ali Abazari
  • 429
  • 4
  • 20