5

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

4
  • I don't understand what you tried (it's pretty unclear to throw a bunch of options like you did). Also, I'd like to see the query. Commented Jun 24, 2010 at 13:25
  • It is a on a Servlet / JSP Page Query query = session.createQuery("from MyTable"); query.setCacheable(false); List<MyTable> bar = query.list(); on the first Call i get the Entries of the Table, then I edit manually some fields, if i call the function again (for example by refreshing/reloading) I get the same result as before Commented Jun 24, 2010 at 13:37
  • are you saving the object after changing it? Are there transactions involved? Commented Jun 24, 2010 at 13:43
  • okay, i forgot to commit the transaction Commented Jun 24, 2010 at 14:06

3 Answers 3

4

I think the configuration you want is

hibernate.cache.use_query_cache = false

Reference.

Sign up to request clarification or add additional context in comments.

1 Comment

this then implies that the query cache is not your problem at all
2

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.

2 Comments

I changed the field in the Table manually and i committed it too
Can you update your question with the code, or at least the fragments relating to editing and updating the entry?
1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.