New .Net Tutorial “Introduction to NHibernate”
Published on November 11th, 2007 by DannyT. Filed under .Net, Best Practices, Development Tools, Visual StudioI’ve just written a new tutorial on NHibernate (an Open Source OR Mapper for .Net).
As ususal any feedback much appreciated.

mizan
December 2nd, 2007 at 5:52 am
good
Anindya Roy Chowdhury
March 1st, 2008 at 7:00 am
Dear Danny,
You did a great job for the learners who are new to Nhibernate. Many many thanks for simplyflying the topics for the Novice.
May be in future i will depend on you when i have to be introduced new technologies.
I really pleased reading a nice topics. Keep going on. Wish you a very bright future.
Avinash Joshi
March 11th, 2008 at 6:08 pm
Unknown entity class: ContactDomain.Contact
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: NHibernate.MappingException: Unknown entity class: ContactDomain.Contact
Source Error:
Line 41: // Tell NHibernate that this object should be saved
Line 42: //session.Save(contact);
Line 43: session.Save(contact);
Line 44:
Line 45: // commit all of the changes to the DB and close the ISession
altins
April 16th, 2008 at 10:17 am
Hi Danny,
Nice to know you.
Nowadays, I am working on one my freelance project (a clinic website) and another project of mine (ebook management system). Actually, I kinda confuse to decide whether I have to use NHibernate or iBatis for both of them. Last year, I used iBatis for my previous project. But, I refer some people said that NHibernate is better and faster than iBatis.
All I know is that iBatis can use Spring for its Business Layer, and UIP as its presentation layer.
I try to find out if NHibernate can do the same thing like iBatis. I mean, can I use Spring for Business Prosess Layer, and if I can use Spring, then How?
And can I also combine UIP with NHibernate? And how do I manage to do this?
Thanks for your tutorial. And I’ll be waiting for your response.
Keep Writing!
Lacuna
May 8th, 2008 at 11:15 am
Very good tutorial although it is a bit annoying that when copy / pasting the code (from Firefox at least) the line number translate into # symbols which you have to go through and take out.
DannyT
May 8th, 2008 at 2:49 pm
To copy click the line above the code samples that says ‘Plain Text’ This will convert the highlighted code to plain text without line numbers
mickster
May 27th, 2008 at 6:58 am
Very nicely done. Although I couldn’t open the solution using .NET 2005 as your example code was created with a newer version. But other than that your post stands head and shoulders above the pack. Good work. I look forward to more on NHibernate and perhaps how it integrates with Spring.NET.
Cheers.
Mike
mkultra
May 29th, 2008 at 4:17 pm
Great tutorial. As a newbie to NHibernate and .NET your walkthrough was very helpful and way more straightforward than the other examples I’ve seen.
Thanks again!!
George
June 12th, 2008 at 9:29 pm
This is great.. .. But.. I am trying to connect with an sql server 2005 , so I would like to know if you have one of these great tutorials for that case..
(:P)
DannyT
June 13th, 2008 at 7:48 am
George, this is the beauty of NH, simply change lines 13-16 of the web.config section in the tutorial to:
<add
key=”hibernate.dialect”
value=”NHibernate.Dialect.MsSql2005Dialect”
/>
and you’re done, it’s also more or less as simple to switch to mysql or oracle databases.
Mark Struzinski
July 4th, 2008 at 3:09 am
Danny,
This was an awesome walk-through, and helped me get through the initial painful steps of learning NHibernate. Any plans on doing the other tutorials you mentioned at the beginning of the post to get into NHibernate in more detail? Again, thanks! This has been a great help!
Raju
July 15th, 2008 at 1:52 pm
This article is really helpful for me. but i need more information about this NHibernet, tell me where i can get this tutorlas.
Thanks
Kamalesh
August 4th, 2008 at 6:57 am
Hi Danny,
Nice to know you.
This is a great tutorial. I am facing some problems in it. I use a PostgreSQLDialect connection & database connectivity was successful. I have created the required table with the fields. In Postgres i am using a sequence to generate ID. My doubt is where in the project i have to place the HBM mapping file (ie) inside Bin or AppCode, & what should be changed inside the HBM mapping for the “ID” column and my other doubt is i am not able to see the Embedded resource property anywhere in my project so that i can set the build action. rite now i am not able to generate DLL’s on runtime
Please help !!!
pan
October 3rd, 2009 at 4:23 pm
Danny
It seems the full source is not available
shri
March 1st, 2010 at 6:45 am
Source Code link error..file not available for download
mo
April 29th, 2010 at 6:22 pm
Great NHibernate tutorial, thanks. Lets have some more, cheers mate.
mont
May 28th, 2010 at 10:01 am
it really a nice tutorial for the beginners who want to start with nhibernate. please upload some advance tutorial on this.