Evidently I was really wrong in this thread
Should I always use transactions in nhibernate (even for simple reads and writes)?
how is it that you can get an inconsistent result from a read without a transaction?
edit — the original question was in the context of nhibernate. Is this nhibernate specific?
No, it is not hibernate specific.
Short answer: Transactions are “atomic units of work” with a consistent view of the world. Once the transaction is left the protected “view” needs to be rectified with the view of the world (COMMITTTED) — or, in the case of a read-only transaction, the consistent view can simply be absolved (it only needed to be consistent during the transaction).
Longer answer: There are many different types of transactions (READ UNCOMMITTED, READ COMMITTED, SERIALIZABLE, REPEATABLE READ, etc.) that affect the fine details.
See Wiki: Database Transaction and Isolation (DBMS) — the latter takes a few link clicks to find 🙂
Imagine this quickly contrived sequence, A and B represent different actors using the DB and each action runs in it’s own one-off implicit transaction (and nothing else):
See the “Example Queries” section of the Isolation wiki article.