Geeks With Blogs
Bob Palmer's Developer Blog .NET, SQL, and Silverlight Development

This is the second in a series of tutorials I am working on to help developers quickly get up to speed with NHibernate.  In this tutorial, I'll be focusing on an implementation of a repository pattern.

As always, comments, suggestions, and any technical bits I may have missed are always appreciated!

You can view the entire article via this Google Docs link:

http://docs.google.com/Doc?docid=0AUP-rKyyUMKhZGczejdxeHZfMTVjMnBqYjVnNw&hl=en

Enjoy!
-Bob

Posted on Saturday, April 17, 2010 12:07 PM | Back to top


Comments on this post: Implementing a Repository with NHibernate - Quickstart with NHibernate (part 2)

# re: Implementing a Repository with NHibernate - Quickstart with NHibernate (part 2)
Requesting Gravatar...
Great article... Just one suggestion - your link to geekswithblogs at the bottom of the article has a typo, you might want to fix that.
Left by thorkia on Apr 17, 2010 4:13 PM

# re: Implementing a Repository with NHibernate - Quickstart with NHibernate (part 2)
Requesting Gravatar...
Thanks for the catch!
Left by Bob Palmer on Apr 17, 2010 5:17 PM

# re: Implementing a Repository with NHibernate - Quickstart with NHibernate (part 2)
Requesting Gravatar...
Really interesting article series!
Looking forward to the next one!
Left by Erik on Apr 19, 2010 6:43 AM

# re: Implementing a Repository with NHibernate - Quickstart with NHibernate (part 2)
Requesting Gravatar...
I thoroughly enjoyed reading your tutorials! Not only are they are really great in introducing one to nhibernate, your project organization tips provide guidelines for modular development.
Left by Badi on May 10, 2010 4:55 PM

# re: Implementing a Repository with NHibernate - Quickstart with NHibernate (part 2)
Requesting Gravatar...
Very helpful tutorial :) If someone want to start NHibernate adventure it is perfect place :)

I have one question to SessionProvider class, why it is not a static class ? ;)
Left by Jacek Spólnik on Jun 16, 2010 9:13 AM

# re: Implementing a Repository with NHibernate - Quickstart with NHibernate (part 2)
Requesting Gravatar...
I have enjoyed the series so far, but I keep getting the following error: “Unable to load type 'NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle' during configuration of proxy factory class.
Possible causes are:
- The NHibernate.Bytecode provider assembly was not deployed.
- The typeName used to initialize the 'proxyfactory.factory_class' property of the session-factory section is not well formed.”

It call stack starts with ProductRepository.Save > ProductRepository.GetSession > SessionProvider.SessionFactory.Get > SessionProvider.CreateSessionFactory and the error occurs on Config.BuildSessionFactory.

I’ve added and dropped references and have gone over the code line by line several times.

Do you have any suggestions?

Thanks.
Left by Jack on Jul 28, 2010 11:04 AM

# re: Implementing a Repository with NHibernate - Quickstart with NHibernate (part 2)
Requesting Gravatar...
Update: I added a reference to NHibernate.ByteCode.Castle on the ACME.Console project and the issue went away.
Left by Jack on Jul 28, 2010 2:54 PM

# re: Implementing a Repository with NHibernate - Quickstart with NHibernate (part 2)
Requesting Gravatar...
I was getting the error No persister for: ACME.Model.Product.I changed the line _config.AddAssembly(Assembly.GetCallingAssembly()); to _config.AddAssembly("ACME.console"); in the ACME.Data project and it worked
Left by nelson on Aug 31, 2010 2:22 AM

# re: Implementing a Repository with NHibernate - Quickstart with NHibernate (part 2)
Requesting Gravatar...
I run into the same issue: No persister for ACME.Model.Product - but the solution from nelson doesn't work for me. Is there another reason for this error?
Left by Matthias on Aug 31, 2010 5:37 AM

# re: Implementing a Repository with NHibernate - Quickstart with NHibernate (part 2)
Requesting Gravatar...
A couple of quick checks if you get a no persister error (either in these projects or in general).

- Make sure your hbm.xml files are set to be embedded resources (easy to miss this one)
- Make sure you name your mapping files *.hbm.xml (once spent half a morning scratching my head because I forgot the .hbm)

Let me know if either of these do not work and I can lend a hand!
Left by Bob Palmer on Aug 31, 2010 5:43 AM

# re: Implementing a Repository with NHibernate - Quickstart with NHibernate (part 2)
Requesting Gravatar...
Your are right - i miss to set hbm.xml-file to embedded resources. I will never miss it again ;-)
Left by Matthias on Aug 31, 2010 6:00 AM

# re: Implementing a Repository with NHibernate - Quickstart with NHibernate (part 2)
Requesting Gravatar...
Tat was good!! can you pl explain what is Lazy loading
Left by Vijayan on May 03, 2011 7:46 AM

Your comment:
 (will show your gravatar)


Copyright © BobPalmer | Powered by: GeeksWithBlogs.net