Maksim Maksim - 8 months ago 35
Java Question

Force clear EJB3 cache in Glassfish

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?


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.