BT

Learn NHibernate with The Summer of NHibernate

by Robert Bazinet on Jul 31, 2008 |

NHibernate has grown in popularity lately with more wide-spread use because of ALT.NET and competing technologies such as the Microsoft Entity Framework.  A new screen cast series called The Summer of NHibernate has been created to expose more developers to this technology. 

NHibernate is a port of the Java Hibernate Core to the Microsoft .NET Framework.  It is an Object-Relational Mapper (OR/M) whose purpose is persisting .NET objects to a relational database.  The term OR/M can give developers the impression of  complex configuration and steep learning curve. 

This does not need to be the case thanks to Steve Bohlen for creating The Summer of NHibernate screen cast series.  Steve describes the series as:

I am producing a series of successive screencast sessions that cover the complete use and implementation of NHibernate.  Called Summer of NHibernate, this series of screencasts is designed to take the newbie who knows nothing at all about NHibernate and teach them everything they need to know to start using NHibernate in a real-world application by the end of the hot summer months.  These screencasts will act as a set of reference materials that we can provide to new hires to help them get ramped up on the use of NHibernate in a short-order.

The series currently has a total of 6 sessions starting from the very basics of setting up and getting started with NHibernate to significant more detail.  Each screen cast runs about 90 minutes and detail of each new episode is posted along with the source code on the web site.

Example content of the first episode include:

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

 More information about the series can be found on The Summer of NHibernate web site and details of each episode can be found on Steven's blog.

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2014 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT