Hibernate disable Query Cache
Following problem:
I create a Query to display all Entries of开发者_StackOverflow a MYSQL Table, if I edit a Field and execute the Query again I get the same (old) Result as in the first query.
It seems that Hibernate caches the Result. I tried to disable Caching with
query.setCachable(false)
"hibernate.cache.use_second_level_cache"
"cache.provider_class"
"org.hibernate.cacheable"
flushing and closing the session
but nothing works
I think the configuration you want is
hibernate.cache.use_query_cache = false
Reference.
Could it be that you never saved or updated the the changed entry to hibernate? When the cache returns the wrong result that is usually an indication something else is wrong.
it has nothing to do with 2nd or Query caches, these are already disabled by default! What probably would help in your case is to call session.refresh(yourEntity)
so that the state of your entity would be re-read by hibernate.
精彩评论