How do I totally disable caching in nHibernate?
NHibernate will evict associated entities automatically if the association is mapped with cascade="all" or cascade="all-delete-orphan". The ISession also provides a Contains() method to determine if an instance belongs to the session cache. To completely evict all objects from the session cache, call ISession. Clear().
An NHibernate session has an internal (first-level) cache where it keeps its entities. There is no sharing between these caches - a first-level cache belongs to a given session and is destroyed with it. NHibernate provides a second-level cache system; it works at the session factory level.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With