0

Sometimes I have a problem, that models working without commiting transaction fail to work when Hibernate commits the data and needs to read it from database.

Is there a possibility for testing to turn off Hibernate caching and work only with database state? Desired would be that when I save the Entity of id=1, then when I want to retrieve it then hibernate should query database.

oneat
  • 10,778
  • 16
  • 52
  • 70
  • Does this answer your question? [hibernate disabling cache](https://stackoverflow.com/questions/6830618/hibernate-disabling-cache) – divyang4481 Jun 10 '21 at 14:04
  • refer https://stackoverflow.com/questions/6830618/hibernate-disabling-cache – divyang4481 Jun 10 '21 at 14:05
  • What you seem to be after is disabling the 1st level cache. I'm not sure this actually can be disabled but have a look here: https://stackoverflow.com/questions/34162560/how-can-i-stop-java-or-hibernate-caching . However, this feels like a xy-problem so could you elaborate a little, e.g. give an example of what works without committing and what doesn't? Are you familiar with the way Hibernate's first level cache as well as DB transaction isolation works? – Thomas Jun 10 '21 at 14:09

0 Answers0