开发者

Hibernate disable Query Cache

开发者 https://www.devze.com 2023-01-04 19:46 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消