could not initialize proxy - no Session when accessing lazy-loaded collection
29K reputation · 12 Jan 2025, 03:49 UTC
The goal is to lower CPU and memory consumption for a low‑traffic NHibernate‑based web or service application while preventing LazyInitializationException when lazy‑loaded collections are accessed after the session is closed.
Constraints include choosing appropriate second‑level cache regions and expiration policies, setting an AdoBatchSize that balances batch overhead with occasional bulk loads, deciding whether to use FlushMode.Commit or Auto, and determining when a StatelessSession is safe for read‑only reporting without introducing mapping or consistency issues.
What AdoBatchSize range yields the best trade‑off for infrequent bulk inserts/updates in a low‑traffic scenario? How should second‑level cache regions be sized and expired to avoid stale data while still reducing database round‑trips? When using StatelessSession for bulk read‑only operations, what precautions are needed to avoid missing properties or association loading problems?
1 answer
0 question comments
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.