Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at
Getting Started with NHibernate: Part III - Updated

I've updated the mapping files for Comment and BlogPost in Part III.

The changes are:

  1. The named query GetCommentsByBlogPostID has been moved into the BlogPost.hbm.xml file, it just makes more sense for it to be there.
  2. <loader query-ref="GetCommentsByBlogPostID"/> was added to the Comments collection mapping in the BlogPost.hbm.xml file, NHibernate will use this query when loading the collection.
  3. cascade="delete", and inverse="true" attributes were added to the Comments collection mapping in the BlogPost.hbm.xml file, the combination of these two setting ensure that when a BlogPost is deleted all of the comments associated with it will also be deleted.  It is unlikely that you would want to delete a BlogPost and all it's comments in a live blog application (although you might want to archive or hide them) but here it serves the purpose of demonstrating these attributes usage.
  4. The Comment mapping file (Comment.hbm.xml) was updated to include a stored procedure call for loading comment entities by ID.

These changes will be covered in greater detail as the application progresses.  Part IV is coming soon and will include all updates, source code, and SQL Express database.

Posted 05-30-2007 2:49 PM by anortham


About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Google Reader or Homepage Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of
Red-Gate Tools For SQL and .NET


SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
NHibernate Profiler
Balsamiq Mockups
JetBrains - ReSharper
Web Sequence Diagrams
Ducksboard<-- NEW Friend!


Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers


Community Server (Commercial Edition)