Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I agree, there aren't many examples for stateful apps. I'm thinking of doing the following:</p> <p>Like you I have a windows service hosting a number of WCF services. So the WCF services are the entry points. Ultimately all my WCF services inherit from AbstractService - which handles a lot of logging and basic DB inserts/updates.</p> <p>In one of the best NHibernate posts I've seen, a HttpModule does the following: see <a href="http://www.codeproject.com/KB/architecture/NHibernateBestPractices.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/architecture/NHibernateBestPractices.aspx</a></p> <pre><code>private void BeginTransaction(object sender, EventArgs e) { NHibernateSessionManager.Instance.BeginTransaction(); } private void CommitAndCloseSession(object sender, EventArgs e) { try { NHibernateSessionManager.Instance.CommitTransaction(); } finally { NHibernateSessionManager.Instance.CloseSession(); } } </code></pre> <hr> <p>So perhaps I should do something similar in AbstractService. So effectively I'll end up with a session per service invocation. If you examine the NHib best practices article link above, you'll see that the NHibernateSessionManager should deal with everything else, as long as I open and close the session (AbstractService constructor and destructor).</p> <p>Just a thought. But I'm experiencing errors because my session seems to be hanging around for too long, and I'm getting the infamous error - NHibernate.AssertionFailure: null id in entry (don't flush the Session after an exception occurs).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload