kavya
kavya

Reputation: 182

Can I disable First level cache in Hibernate?

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

If yes how?

Upvotes: 0

Views: 1686

Answers (2)

Wilder Valera
Wilder Valera

Reputation: 1019

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

Upvotes: 0

Zeromus
Zeromus

Reputation: 4542

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

Upvotes: 1

Related Questions