Summer of NHibernate Session 01: Setup and Basic Usage Pattern Screencast is Available
I am pleased to announce that the first installment of the Summer NHibernate screencast series is finally available for download!
This first session covers the basic setup and usage patterns of the NHibernate object relational mapping technology and starts with the basics assuming no familiarity on the part of the user with NHibernate at all. For background on the reasoning behind this video series refer to this previous post.
Screencast Session Outline
Session 1 (6/13): SETUP AND BASIC USAGE PATTERN
- Get the NHibernate dlls and .xsd files
- Demonstrate how to add the xsd files to VS XML intellisense capabilities to get syntax support in the XML files
- Use a simple Customer — Orders — OrderItems style database
- Hand-code DTO class for the ‘Customer’ table
- Introduce the concepts of 1:1 relation between table and class
- (the dumb-DTO pattern; start here since it’s by far the simplest way to work)
- Hand-code the Customer.hbm.xml mapping file to expose people to this syntax
- Hand-code the hibernate.cfg.xml file to expose people to this syntax
- Setup the project in VS (data access class lib)
- Setup a corresponding test class to go along with it (to be used to exercise the data access class lib)
- Further demonstrates the value of unit tests as a ‘harness’ for exercising concepts in a safe vacuum
- Code a simple method that demonstrates the basic mechanics of interacting with NHibernate to retrieve all Customers from the database
- ISessionFactory, ISession, reading configuration(s)
- Leveraging the using ( ) {…} block to ensure session is properly closes/disposed of when done
Screencast format and Download Server
So that a high visual quality for sessions can be maintained, these Screencasts are being recorded at a relatively high resolution of 1280×1024 and are projected to run for between an hour and an hour and a half in length. As such the total download is easily a couple hundred megabytes in size and since I’m too frugal to spring for a for-fee download site for the content I have instead chosen to post the sessions at the www.4Shared.com web site. I have isntead chosen to post the content on the www.drop.io web site.
4shared.com drop.io is a free content hosting site offering unlimited bandwidth and 5 GB of unlimited concurrent storage but there is a limitation that no single file can exceed 100 MB in individual size. To circumvent this limitation I will be breaking the Screencast into two or more multipart ZIP files, each one just slightly under 100 MB of capacity. In order to unzip the AVI file you will need to download all three parts of the multipart ZIP file listed below. An additional download has also been provided containing the source code for the session used in the video for those interested in exploring the code.
While this approach results in a larger number of individual files to download, it allows me to post the content and make it available at a location with no bandwidth limitations associated with it.
As usual, comments and suggestions are welcome!
Download links for Session 01
Note that as with all of these screencasts, to successfully view them on your computer you will need to download and install the TechSmith Camtasia Codec.![]()

- Summer of NHibernate Session 01 Screencast Part 1 of 3
- Summer of NHibernate Session 01 Screencast Part 2 of 3
- Summer of NHibernate Session 01 Screencast Part 3 of 3
- Summer of NHibernate Session 01 Code Sample
Update: As mentioned here, all content has been moved to the Summer of NHibernate Web Site.


When I try to extract the zip…”Summer of NHibernate Session 01 Screencast Part 1 of 3″…I get an error. The error states that the file is corrupted. Can you help me?
July 14th, 2008 at 12:56 pmI am 22 minutes into the screencast, which is great so far, and you mention some “class cleaner code” that seems to format your class nicely. Is this something that you have done using CodeRush? I waste a lot of time manually cleaning up my classes after using CR to create the properties etc.
Thanks for creating these screencasts.
July 15th, 2008 at 6:14 amIndeed it is via CodeRush though actually its via an OSS plugin that runs atop the DXCore libraries and doesn’t actually require CodeRush.
For more detail (including links and a watch-out-for note about it), I just posted about some of the tools in the screencasts here: http://unhandled-exceptions.com/blog/index.php/2008/07/16/confessions-of-a-developer-tool-hound/
July 16th, 2008 at 11:10 pm@daav817
Instead of the multi-part ZIP files, just instead go directly to the http://www.summerofnhibernate.com site and download the single complete AVI directly from the link there.
Reliability of the links on drop.io is just one of the reasons I switched from that distribution method to the more sane approach of placing links to each complete file on a site unto themselves.
Let me know if this solves the problem for you or not.
July 16th, 2008 at 11:13 pmHey Mr. Tool Hound!:-)
July 27th, 2008 at 2:59 amWhat tool do you use to generate those .hbm.xml files? I bet you don’t write all of those manually from scratch, right?
Cheers, Marc
@marc:
Sure enough, no I usually don’t. An upcoming session will cover tools that we use to slave the DTOs and hbm files to the database schema (as well as tools we use to slave the DB schema to the DTOs and hbm files when that’s more appropriate too.
We use a custom MyGeneration template (http://www.mygenerationsoftware.com) set to generate them as part of the build process.
July 27th, 2008 at 4:56 pmI love MyGeneration! Can I get a copy of the MyGeneration templates you use?
August 1st, 2008 at 8:16 pm@Dan:
These (the templates) will be available as part of the code-download that accompanies the session where I talk about how to use them to have the DB drive the generation of the DTO classes and the .hbm.xml mapping files. Patience — this session is but a few installments away
August 1st, 2008 at 9:34 pmHi Steve,
videos are great i mean superb and you did a excellent job and if i haven’t get hold of your web site then i might have lost or never use nhibernate, thanks again.
question for you
in your class library project in class you right click you get the options of Test, Test with Debugger….etc.. how did you got that? is that VS2008 or do i have to download any addons (mbUnit) ?
i installed MbUnit but I don’t see the options you have.
any help?
thanks
August 13th, 2008 at 7:33 pm@Nisar:
Thanks for the feedback; I’m glad you’re finding the content to be helpful — I hope its gelping you to beecome a more effective adopeter of NHibernate.
It may not surprise you to discover that I have a blog post about your specific question:
http://unhandled-exceptions.com/blog/index.php/2008/07/16/confessions-of-a-developer-tool-hound/
The tool that provides those ‘Test with…’ options is called TestDriven.NET and its listed there in that post about tooling. Hope this helps~!
-Steve B.
August 13th, 2008 at 8:32 pmThanks for these great NHibernate videos. I have never learn so much in such a short time. You are amazing. XML configuration and mapping topics are the ones that scared me on all these days from NHibernate. You really made those topics enjoyable and i never thought Visual Studio can help me that much in XML side!. Will you make screen casts on spring framework for .net?. Hearty thanks for upgrading me to the next level.
September 16th, 2008 at 9:04 am@Suhair:
Thanks for the feedback; I’m glad you’re finding value in the content and I hope this helps to make NHibernate a little more approachable for you — its really not that bad once you get your head into it but the dearth of resources that are scattered all over the internet makes it pretty unfriendly to the newbie (which tends to reduce its adoptability by all but the most persistent developers).
Re: spring.net, I’m not really a Spring.NET guy so its unlikely that i will produce content on that framework although I am an avid CASTLE PROJECT adopter and so will likely be offering content on at least some of the larger components in the Castle framework (http://www.castleproject.org) later in the year or early next year depending on my schedule.
September 16th, 2008 at 10:23 amvery good
October 12th, 2008 at 8:48 pmI rerun the video and I have a trouble, when I execute (compilation ok) a test:
(…)failed: could not load an entity(…)
I use NH 2.0.1, VS2008SP1 on Vista x64SP1, SQLServer 2008 Std
Customer.hbm.xml
hibernate.cfg.xml
NHibernate.Connection.DriverConnectionProvider
NHibernate.Driver.SqlClientDriver
Data Source=ZEUS;Initial Catalog=AdventureWorksLT2008;Integrated Security=True
true
NHibernate.Dialect.MsSql2000Dialect
Do you have an idea ?
November 10th, 2008 at 4:14 am@Kris-I:
From this line, you are using the MSSQL2000 dialect on a SQLServer2008 platform…
NHibernate.Dialect.MsSql2000Dialect
THere is not yet a dialect avaialable to support MSSQL2008 and I have no practical experience using NHibernate with SQLServer2008, but I can recommend that you try the NHibernate.Dialect.MsSql2005Dialect instead as its much closer in surface area to the 2008 t-SQL syntax.
There are (as far as I know) several new datatypes introduced in MSSQL2008 for which there is no support in NHibernate (the new lightweight date-time constructs, the spatial types, etc.) but I believe that if you stay away from those data types that didn’t exist in SQLServer 2005 the Nhib 2005 sql server dialect should work.
Also, please ensure that you have watched ALL of the videos as its not until the last installment that I go through the steps needed to make the persitent classes work under NHib 2.x so make sure that you have followed those specific steps rather that attempting to apply what’s shown in earlier screencasts directly to Nhib 2.x-based code of your own.
Hope this helps~!
November 10th, 2008 at 7:41 am