Reputation: 71
Following problem:
I create a Query to display all Entries of 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
Upvotes: 5
Views: 12818
Reputation: 2600
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.
Upvotes: 1
Reputation: 35331
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.
Upvotes: 2