0

Can I disable First Level Cache in Hibernate, if I want?

If yes how?

kavya
  • 182
  • 3
  • 15
  • 1
    "Disable first level cache in hibernate" what result will google return ? any relevant result? – VedantK Jan 19 '18 at 13:51
  • Possible duplicate of [How can I stop Java or Hibernate Caching](https://stackoverflow.com/questions/34162560/how-can-i-stop-java-or-hibernate-caching) – VedantK Jan 19 '18 at 13:51

2 Answers2

1

No, it's the default and there is no way to disable the first level cache.

One thing you can do is clear it everytime you query, but i don't really see the point.

The only situation that i can think of that could give problem is when you have a session where you fetch from db a lot of object for reading and you don't need them in cache. But even then you can query for single field instead of whole object to avoid caching it

Zeromus
  • 4,472
  • 8
  • 32
  • 40
0

NOPE, you can't.

You can have no interaction with the first level cache with StatelessSession. Read more about it in https://docs.jboss.org/hibernate/orm/5.2/userguide/html_single/chapters/batch/Batching.html

Wilder Valera
  • 986
  • 9
  • 11