I've updated the mapping files for Comment and BlogPost in Part III.
The changes are:
- The named query GetCommentsByBlogPostID has been moved into the BlogPost.hbm.xml file, it just makes more sense for it to be there.
- <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.
- 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.
- 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