Real World NHibernate Screen Cast: Planning

time to read 2 min | 326 words

Did you noticed? Most of the guidance about tools are about how to get you started, but much more light on how to get going in the face of real world scenarios. NHibernate is no exception in this regard, so you can find a lot of information about getting started, but far less on how to actually deal with it.

So this is a official solicitation of interesting NHibernate issues that you have run into. When I first thought about it, I figured out that querying was where most of the interest lay (that is certainly where I mostly sit back and say "I can't believe I just did that so easily"), but mapping issues, or dealing with general problems are also welcomed.

A question should include the problem statement and the scenario and a description of the entities / database in question, if they are relevant. I may contact you for more information regarding this problem.

Here is an example of a question that I can't really do much about:

How can I make NHibernate skip persisting unsaved entities?

This is problematic because you have already arrived to the conclusion of what you want to do, but I have no idea what you are trying to do, or why. Often, there are other ways to do the same thing, but without the scenario, I can't tell. A better way to ask this question is:

We have a "Simulation Mode" in our applications, in which a user can do things to the application without really affecting the system, for trying things out. We want to use the same code as we use for the real thing, but we must not save to the database, obviously. How can I stop NHibernate stop persisting my entities?

This gives me enough background to know to tell you to go to set session.FlushMode to FlushMode.Never.

So, post those problems here, and I'll try to give coherent solutions to them.