Maksim Maksim - 1 year ago 178
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?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download