Search code examples
javacachingglassfishejb-3.0toplink-essentials

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?


Solution

  • 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.