﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>alberto commented on How to review NHibernate application</title><description>I understand, but I would not expect find a "worst practice" in an example trying to show how to use a tool. And if there is one, it should be clearly stated. Otherwise, when I read it I think "this is the way it should be done". For the very same reasons that I wouldn't teach someone how to write sql sentences by doing string concat without putting a BIG, blinking warning.
  
  
That said, I'm still struggling for a good example that doesn't force me into a bunch of totally unrelated stuff, like ioc or mvc (ok, I know it's not unrelated, but it should not be there adding complexity to the example).
  
  
The best one I have found so far is Exesto, but if it's so hard to find a decent example, I can't imagine how difficult it will be for advanced topics. The nhibernate tutorials @ http://www.hibernate.org/365.html are discouraging, with broken or outdated links.
</description><link>http://ayende.com/3442/how-to-review-nhibernate-application#comment16</link><guid>http://ayende.com/3442/how-to-review-nhibernate-application#comment16</guid><pubDate>Mon, 04 Aug 2008 16:16:12 GMT</pubDate></item><item><title>Lucio commented on How to review NHibernate application</title><description>@alberto That sample has to be simplified. Otherwise you'd scare a first-timer away from NHibernate, and you don't want that :P
</description><link>http://ayende.com/3442/how-to-review-nhibernate-application#comment15</link><guid>http://ayende.com/3442/how-to-review-nhibernate-application#comment15</guid><pubDate>Sat, 02 Aug 2008 12:11:21 GMT</pubDate></item><item><title>Ayende Rahien commented on How to review NHibernate application</title><description>alberto,
  
That is a problem in general, because samples are inherently trying to simplify everything except what they are demonstrating.
  
</description><link>http://ayende.com/3442/how-to-review-nhibernate-application#comment14</link><guid>http://ayende.com/3442/how-to-review-nhibernate-application#comment14</guid><pubDate>Fri, 01 Aug 2008 19:29:52 GMT</pubDate></item><item><title>alberto commented on How to review NHibernate application</title><description>Unfortunately, the "first application" in nhibernate faq ( http://blogs.hibernatingrhinos.com/nhibernate/archive/2008/04/01/your-first-nhibernate-based-application.aspx ) does the two things you discourage for session management. It's hard to find a good Nhibernate/ActiveRecord example to follow without findind someone else discouraging some of the practices shown in it.
  
</description><link>http://ayende.com/3442/how-to-review-nhibernate-application#comment13</link><guid>http://ayende.com/3442/how-to-review-nhibernate-application#comment13</guid><pubDate>Fri, 01 Aug 2008 19:24:48 GMT</pubDate></item><item><title>Frederik Gheysels commented on How to review NHibernate application</title><description>The article on codeplex seems interesting as well.  However, I'd like to see an example app of a Winforms application as well.
  
Im struggling a bit on how to do session managment there ...
  
I use long sessions, but ... do you keep the session connected to the DB for the duration of the session ?
  
If you don't use long sessions, you have a chance that unnecessary update statements are issued to the DB (or maybe I'm doing something completely wrong ... ).
  
I'd like to see some input 'bout that.
</description><link>http://ayende.com/3442/how-to-review-nhibernate-application#comment12</link><guid>http://ayende.com/3442/how-to-review-nhibernate-application#comment12</guid><pubDate>Fri, 25 Jul 2008 16:34:41 GMT</pubDate></item><item><title>Nathan commented on How to review NHibernate application</title><description>Thanks Frederik, that is an awesome article. The article is here: http://www.codeproject.com/KB/architecture/NHibernateBestPractices.aspx. That author also has a framework cooking on CodeProject that incorporates NHibernate and MVC and emphasises DDD - it is here: http://www.codeplex.com/SharpArchitecture. So much to learn, so little time :) 
</description><link>http://ayende.com/3442/how-to-review-nhibernate-application#comment11</link><guid>http://ayende.com/3442/how-to-review-nhibernate-application#comment11</guid><pubDate>Fri, 25 Jul 2008 15:30:50 GMT</pubDate></item><item><title>Bill Pierce commented on How to review NHibernate application</title><description>I knew something was implicit, but I had it backwards, rollback is implicit if not explicitly committed.
</description><link>http://ayende.com/3442/how-to-review-nhibernate-application#comment10</link><guid>http://ayende.com/3442/how-to-review-nhibernate-application#comment10</guid><pubDate>Fri, 25 Jul 2008 14:20:30 GMT</pubDate></item><item><title>Bill Pierce commented on How to review NHibernate application</title><description>"Don't forget to commit :-)"
  
  
I thought Transactions were implicitly committed upon disposal if no exception was thrown and it was not explicitly rolled back?
</description><link>http://ayende.com/3442/how-to-review-nhibernate-application#comment9</link><guid>http://ayende.com/3442/how-to-review-nhibernate-application#comment9</guid><pubDate>Fri, 25 Jul 2008 14:10:53 GMT</pubDate></item><item><title>Frederik Gheysels commented on How to review NHibernate application</title><description>@DannyT &amp; Nathan:  I'm using the NHibernate Ref. Guide (which you can find on the nhibernate webpage).  I've also used the article by Billy McCafferty on CodeProject as a reference.
  
</description><link>http://ayende.com/3442/how-to-review-nhibernate-application#comment8</link><guid>http://ayende.com/3442/how-to-review-nhibernate-application#comment8</guid><pubDate>Fri, 25 Jul 2008 09:37:53 GMT</pubDate></item><item><title>Nathan commented on How to review NHibernate application</title><description>I would like to echo Danny's question - for those of us who are not seasoned NHibernate users (but would like to understand how to use it correctly) a best practices example no matter how simple would be worth its weight in gold. Also - is anyone aware of a tool that can generate both NHibernate mappings / Database Schema Sync Scripts from a metadata model? :) 
</description><link>http://ayende.com/3442/how-to-review-nhibernate-application#comment7</link><guid>http://ayende.com/3442/how-to-review-nhibernate-application#comment7</guid><pubDate>Fri, 25 Jul 2008 00:59:44 GMT</pubDate></item><item><title>Rob commented on How to review NHibernate application</title><description>Ayende, I would love to see you do some posts addressing the above questions.  I think a lot of people could benefit from some more information.
</description><link>http://ayende.com/3442/how-to-review-nhibernate-application#comment6</link><guid>http://ayende.com/3442/how-to-review-nhibernate-application#comment6</guid><pubDate>Fri, 25 Jul 2008 00:58:21 GMT</pubDate></item><item><title>DannyT commented on How to review NHibernate application</title><description>Ayende, do you happen to have (or know of) a simple sample NH project that you would consider best practice that people (namely me) could refer to when getting started with NH?
  
  
I've been using it for a couple of months now and still struggle with the numerous ways there are to do things but not knowing which is the best approach to follow.
  
  
Dan
</description><link>http://ayende.com/3442/how-to-review-nhibernate-application#comment5</link><guid>http://ayende.com/3442/how-to-review-nhibernate-application#comment5</guid><pubDate>Thu, 24 Jul 2008 22:42:29 GMT</pubDate></item><item><title>Frederik Gheysels commented on How to review NHibernate application</title><description>@Frank Quednau :  What Ayende wants to say -imho- is that you should start a new session in every method of your repository.   
  
Why not: your repository doesn't know if there are other repository-methods that are to be executed which could use the same session, or even worse, it could be that you want to save numerous other objects in the same transaction. 
  
When you open a session or start a transaction in your repository method, you are in no way able to save multiple objects in one transaction.
  
Therefore, it is the 'consumer' of the domain model (the repository is part of the domain model) which should decide when to open and close a session, and when to start / commit a transaction.
  
  
You could ofcourse start a session in your client, pass that session to instances of the repository, and let the repository work with that session.
</description><link>http://ayende.com/3442/how-to-review-nhibernate-application#comment4</link><guid>http://ayende.com/3442/how-to-review-nhibernate-application#comment4</guid><pubDate>Thu, 24 Jul 2008 21:41:16 GMT</pubDate></item><item><title>Frederik Gheysels commented on How to review NHibernate application</title><description>I consider myself as a beginner in NHibernate, and I've some questions regarding the tips you've posted here:
  
  
- In which case(s) would you have multiple sessionFactories in one application ?  And why would you benefit from that ?  Wouldn't it make your app more complex / harder to maintain ?   (I think you've to ask yourself the question everytime: what sessionfactory do i need to be able to persist an object of type xyz ? )
  
  
- With contextual session mgment, you mean that it is the consumer of your 'domain' (be it a service interface or your winforms app itself) that should decide when a session is to be opened and closed, or when a transaction should start ?  (That's the part of your app which knows about the context; the context-is-king-idea ? )
</description><link>http://ayende.com/3442/how-to-review-nhibernate-application#comment3</link><guid>http://ayende.com/3442/how-to-review-nhibernate-application#comment3</guid><pubDate>Thu, 24 Jul 2008 21:36:49 GMT</pubDate></item><item><title>Frank Quednau commented on How to review NHibernate application</title><description>Hi,
  
the docs I found on contextual session talk about "GetCurrentSession" and how you can implement the behaviour behind this. Would it be OK for you to point me to why this approach is preferrable? (I didn't understand the multi-tenanting bit)
  
  
e.g. If I have a call to a WCF service and I use some repository, abstracting the NHibernate bits, is it not ok to get a session when the repository is activated and discard it once the repository is also discarded?
  
  
I am still a beginner with Nhibernate and I saw quite a lot of code on the Internet that looks like your worst practice...it would be interesting to hear why it is bad.
  
Cheers
</description><link>http://ayende.com/3442/how-to-review-nhibernate-application#comment2</link><guid>http://ayende.com/3442/how-to-review-nhibernate-application#comment2</guid><pubDate>Thu, 24 Jul 2008 21:36:49 GMT</pubDate></item><item><title>Brian Chavez commented on How to review NHibernate application</title><description>Hi Ayende,
  
  
&gt;&gt;&gt;This allows you to play some very interesting games (such as multi tenanting the application without letting the application know about it).
  
  
Maybe you could you expand on that sometime.  A topic for a future post perhaps, it would be really interesting to see how you would architect a web application with a contextual session management that supports multi tenancy that is a scalable keeping in mind the possiblity of web farms / load balancers.
  
  
-Brian Chavez
</description><link>http://ayende.com/3442/how-to-review-nhibernate-application#comment1</link><guid>http://ayende.com/3442/how-to-review-nhibernate-application#comment1</guid><pubDate>Thu, 24 Jul 2008 21:33:47 GMT</pubDate></item></channel></rss>