Michael
Michael

Reputation: 2510

Invalidate Object In Hibernate 2nd Level Cache

I have an application using Hibernate with ehcache as the 2nd level cache. I have been trying to figure out how I can invalidate a specific object in the cache thereby forcing hibernate to reload it from the database the next time it is referenced.

Is there an easy way to do this?

I've tried several things but so far been unsuccessful. Any suggestions would be appreciated.

Upvotes: 0

Views: 913

Answers (1)

Alex Barnes
Alex Barnes

Reputation: 7218

You can use:

SessionFactory.getCache().evictEntity(Class entityClass, Serializable identifier)

Upvotes: 2

Related Questions