views:

33

answers:

1

I'm writing a soap web service: Jboss + Hibernate + Java. Database on PostrgreSQL. After publishing the webservice, it runs perfectly.

For testing purposes I change data on the database by opening pgAdmin, and changing the values on the rows by hand. Now, the problem is, Hibernate is not aware of those changes. Not until I re-publish the web service.

Is there any way to tell Hibernate to empty the cache or reload the data from the database so it will take the last values available?

Thanks!

A: 

I'm assuming you're talking about the second level cache...

The Cache API exposes several methods allowing to evict various regions. Check all the evictXxx() methods. Use SessionFactory#getCache() to obtain the Cache.

Pascal Thivent
It appears that the evict methods are deprecated...
Hectoret
@Hectoret: No, they are not, not if you use `SessionFactory#getCache()` first as I suggested.
Pascal Thivent