How do I totally disable caching in nHibernate?
Asked
Active
Viewed 1.3k times
17
-
Can you expand to what type of caching you're talking about? – SCdF Sep 22 '08 at 23:41
2 Answers
13
Use the IStatelessSession to bypass the first level cache: http://darioquintana.com.ar/blogging/?p=4
In order to use the second level cache you must explicitly configure it. You will not use it if you don't.
You can also turn off lazy loading in your mappings. lazy=false.

Matt Hinze
- 13,577
- 3
- 35
- 40
-
1Keep in mind that the StatelessSession doesn't lazy-load and performs updates and inserts rather than saves. Also with StatelessSession you will probably have issues with Cascading. – Don Rolling May 24 '12 at 21:08
-
Yeah, this is an issue for me. I have my regular connection querying for each loop, but then run a stored proc to do a bulk update at the end of each loop. Not able to switch to a stateless session... – ganders Jan 19 '15 at 07:19
5
Note IStatelessSession is I think new in Nhibernate 2.0
second level cache configuration details : Chapter 25. NHibernate.Caches

Spivonious
- 718
- 7
- 20

Richard
- 1,804
- 16
- 22