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?
I 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.
Indeed 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/
@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.
Hey Mr. Tool Hound!:-)
What 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.
I love MyGeneration! Can I get a copy of the MyGeneration templates you use?
@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 🙂
Hi 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
@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.
Thanks 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.
@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.
I 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 ?
@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~!
i’m a developer trying to get a job.I’m from India.
It was great help for me but i’m very sorry i couldn’t donate.
I assure you i’ll do so if i get a job.
Great stuff guys.
Thanks
Abid
@Abid:
Glad to hear you’re enjoying the content and don’t worry about not being able to donate — that VAST majority of viewers didn’t so it places you in good company (or at least LARGE company!).
Feel free to give what you can when you can — any help would be appreiated.
Best of luck in your job search~!
I’ve heard great things about these videos but am having an aweful time trying to get them downloaded. The download starts out okay, but once it gets to 6-8Mb downloaded, it slows down to a crawl (only downloading 1 video–saving to disk).
Did the site hit some kind of bandwidth restriction? Is there an alternate mirror to download from?
@Sam:
There’s no bandwidth restriction on the site, so I’m afraid if you are having issues its probably with your own ISP (or even my hosting provider if they are experiencing any intermittent troubles).
Perhaps either try the download from another location (e.g., work vs. home, etc.) or else simply try the download again at a different time of day. I’ve rec’d no other reports from folks having trouble downloading so I’m guessing its on your side.
Let me know how you make out~!
Your time and effort in creating the videos are very much appreciated.
Thank you again.
@cash pat:
That depends on what you mean by ‘validate’. The issue of ‘business object validation’ tends to rapidly devolve into holy wars as its something that people tend to have strong ‘beliefs’ about the ‘correct’ way to handle it.
Some believe “it should never be possible to have your object in an invalid state” and so guard clauses in property setters, objects that can only be ‘setup’ via their constructors (and the constructor code ensures validity of the object, etc.). This kind of (somewhat draconian) approach makes validation simple: if you have an object, by definition its ‘valid’ already.
Others trend towards having a “.Validate()” method on the object that can throw meaningful exceptions if the object is invalid (often abstract in the base class so subclasses are forced to implement the method). A variant of this approach is the “.IsValid()” method that tends to returm a bool but offers less detailed info about WHY an object might be invalid.
Obviously the CSLA framework trends towards the “.Validate()” method approach, but offers conveniences like the “BrokenRulesCollection” that aggregates details about all of the ways that an object might presently be invalid when you call .Validate(). [note that I’m going completely from 5+ year old memory of how CSLA handles validation — the details of this are probably incorrect, but the semantics are likely still similar all these years later]
In NHibernate, probably the closest thing to the kind of validation framework that is offered by CSLA (in re: collection ‘broken rules’ for you to interact with and respond meaningfully to, etc.) is the excellent NHibernate Validator project. NHibernate Validator (NHV) gives you the ability to perform business rules (and other) validation that plugs into the NH infrastructure but from OUTSIDE your objects, so that validation code doesn’t ‘mess up’ your business objects code directly. I HIGHLY recommend this project for anyone serious about using NH in their work as it very nicely compliments the NH project.
For some reference links on NHV, check out the following…
Using NHV with ASPNET MVC…
http://nhforge.org/blogs/nhibernate/archive/2009/04/02/nhibernate-validator-and-asp-net-mvc.aspx
Fabio (Maulo) digs into how it works…
http://fabiomaulo.blogspot.com/2009/02/diving-in-nhibernatevalidator.html
Ayende gives a simple example…
http://ayende.com/Blog/archive/2009/05/01/nhibernate-validator.aspx
Even the MS Patterns and Practices guys get in on the act…
http://www.pnpguidance.net/post/NHibernateValidatorTutorialValidateBusinessObjectsMVC.aspx
Hope this helps get you started with NHV — using it in conjunction with NH yields a very familiar *result* to using CSLA validation (even as the mechanics of how its achieve are completely different).
Good luck,
-Steve B.
@cash pat:
I live to serve. 🙂
Hope that helps.
-Steve B.
First I would like to say, excellent screencast and tutorial material. I am having a problem running the sample code in VS2008/SQL2008 however. I keep getting ‘object not set to instance’ error when I tried to run the code. I think the problem is in the hibernate.cfg.xml file, but am not sure. I tried another example I found one line that also gave me an error and was able to fix it by adding the NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle
I also added the Castle.Core, Castle.DynamicProxy2 references but it still does not work. Any Ideas ?
Hi Steve,
When playing back the files in Windows Media Player 11 I can’t advance in the video. When I try to advance or backup it starts from the begining.
In Quicktime 7.6.6, it plays the vidio from wherever I want it to but there isn’t any audio.
Any clues as to what I can do?
MArk B.
Hi Mark,
did you install the Techsmith Camtasia Codec on your computer? This is needed for the first 6 sessions at least.
Regards,
Phil
@Phil
Yea, I got the Codec. I thought it was a video driver problem so I tried it on another computer. A laptop. Same problem. However, I had the guy next to me look at the video. He opened it in WMP without the Codec. The audio played and was adjustable in time but there wasn’t a picture.
Funny thing, it did play at home on my personal machine just fine. (After I got the Codec) Didn’t have time at home to watch it though.
MArk B.
In the Summer of NHibernate Web Site when I do click on the link of the video does not show it. Please have your other link available?
@Edgar
The files are huge. They won’t show up until the entire thing has downloaded. That could take from 30 minutes to a couple of hours. As the text indicates, you should right click the link and do a Save As. Then, once the file has downloaded you’d view it from your hard drive.
Remember to get the CODEC for the .avi files as required.
MArk B.
Thanks a lot for you time and effort for all the videos.
It’s the most complete and comprehensive sets of video I found so far…
Many Many thanks again…
Mohammad.
Thank you so much. This series is so great!