JontyMC
JontyMC

Reputation: 6068

Stateless NHibernate for querying

We have a database that is updated via a background process. We are using NHibernate to query the data for display on the web UI, so we don't need change tracking or lazy-loading.

If we mark all the mappings as mutable="false", is this the same as using a stateless session?

Upvotes: 2

Views: 1323

Answers (1)

Diego Mijelshon
Diego Mijelshon

Reputation: 52753

No, it's not the same. In fact, it has absolutely nothing to do with it (i.e. you can modify entities in stateless sessions).

A StatelessSession does not keep track of entities, which results in big performance improvements (both in memory usage and execution times) when you don't need the features that a stateful session provides.

In particular:

  • There is no lazy loading
  • There is no caching
  • There is no cascading
  • All updates must be explicit (insert/update/delete)

Upvotes: 4

Related Questions