background preloader

Nhibernate

Facebook Twitter

Framework

Fluent. Nhcontrib » BurrowHome. Tarantino - Google Code. Your very first NHibernate application – Part 2. In this second part Gabriel Schenker continues his overview of the NHibernate OR/M. Introduction In the first part [1] of this article series I have introduced NHibernate and its sister project Fluent NHibernate. I have discussed the perquisites needed to start developing a NHibernate based application. Finally I have introduced a simple domain model which I then took as a base to implement.

The first entity of this domain was then implemented and mapped. The unit test for the mapping was discussed. In this second part I’ll continue to implement and map the remaining part of the domain. Your very first NHibernate application series Implementing and mapping the remaining domain objects First let’s implement and map the Product class. 1.public class Product 3. public int Id { get; set; } 4. public string Name { get; set; } 5. public decimal UnitPrice { get; set; } 6. public bool Discontinued { get; set; } To keep our sample simple I have only implemented the most important properties. 05. 06.

Troubleshooting common mapping bugs with NHibernate - Derik Whit. For all of its power and glory NHibernate is no different than any other tool which requires you to configure it before you can use it. In the case of NHibernate you need to configure (map) each of the tables you want to access to the various entities in which they are going to populate. And because you need to manually configure this, there is room for mistakes and errors. I wanted to outline some mapping errors I have run into while trying to learn NHibernate and explain how to resolve them. We will be utilizing the FluentNhibernate mapping library to ease the process of creating our NHibernate mappings. Common Issue #1 – Wrong/Invalid Table Name Used In Mapping Issue: When the mapping from an entity to the table is not valid you will receive the below error.

Error: System.Data.SqlClient.SqlException: Invalid object name ‘YourNameHere’ Solution: Ensure that the entity name you are mapping is the same as the database table. Common Issue #2 – Missing primary key mapped for the table. Custom Collections with NHibernate, Part IV: Extensions! - Billy. In part I of this series, we examined motivations for maintaining custom collections that are compliant with NHibernate.

Part II demonstrated the basics behind wiring up a custom collection. Finally, part III refactored the solution into a nice reusable package with minimal intrusion (relatively speaking). My complaint with all of this is that the proposed solution is complicated, difficult to explain, and leans towards Shotgun Surgery by requiring you to change the signature of both the POCO collection as well as the NHibernate collection every time you need to add a new method. That's just not cool. As much bad press that extension methods have received, I have found one instance (and only one so far) when extension methods truly shine: extending collection interfaces, which NHibernate can happily bind to, with custom methods.

Ideally, we want our custom collection to be completely ignorant that it's being bound to by an ORM. So where's the rub? Billy McCafferty. Home - NH Forge. NHibernate - a knol by Fabio Maulo. The Inquisitive Coder - Davy Brion’s Blog » Blog Archive » NHibe. This is the archive of my blog, which used to be hosted on my personal site. It originally had about 650 posts but I removed almost half of them, either because they were outdated, no longer relevant or because I just didn't see any value in the content anymore. Feel free to browse through the archive, or you might want to check out the following pages specifically: New Here? : a categorized overview of my better postsCategories : a list of all of the categories of postsRecommended books : a list of books that I recommend to software developers I started blogging about 5 years ago, and over the years I've published 653 posts.

This will be the last one. I had some specific personal goals in mind when I started blogging, and I've gotten everything I've wanted out of it, and more. I'm not entirely sure yet what I'm going to do with the content on this blog. I will remain active on Twitter and I plan to be more active on GitHub from now on. 4 Comments 0 Comments 7 Comments 0 Comments 5 Comments. Test Your NHibernate Mappings! - Dave Laribee. Disclaimer! Ayende rightly points out that if you are testing your queries you get this mapping test for free. If you aren’t, well put this in place as a stop gap measure (to test mappings) and if you have queries, which you probably do, get to testin’! A while back Bil Simser put up a post on the first test you should write when using Castle Windsor. In it he shows a technique for verifying his component registrations are correct. Since Windsor and NHibernate are the peanut butter and jelly of the ALT.NET crowd, I think we can and should do the same for NHibernate: [Test] public void Verify_NHibernate_mappings() { string myConfigPath = @"wherever\you\put\your\NHibernate\config.xml"; Configuration config = new Configuration(); _sessionFactory = config.Configure(nhibernateConfig).BuildSessionFactory(); } Would that I did this before today.

I’ve learned my lesson. S#arp Architecture: ASP.NET MVC with NHibernate and Spring - Bil. To skip to the chase... It wasn't too many years ago that I used to state quietly that I was a Microsoft web developer. Inevitably, a Java developer would hear my whisper and begin laughing hysterically as I cowered away from defending Active Server Pages. Not long after, I felt a bit more confident defending Microsoft web development after the introduction of ASP.NET but have yet to this day been able to accurately describe the page life cycle or defend why the *%$@ it was ever a good idea. While the .NET language continued to progress into a world class language with generics and LINQ, I often wondered when the presentation layer would get the attention it deserved. To add insult to injury, the Rails crew was quick to join in the hysterics that the Java community had long been enjoying. Focused on Domain Driven Design This architecture places emphasis on the domain as being the core element of focus.

Loosely Coupled Open Ended Presentation. Nhibernate example structure. A few reasons to like NHibernate. NHibernate Best Practices with ASP.NET, 1.2nd Ed. - The Code Pro. Author's note added June 11, 2008 - Announcement of S#arp Architecture Thankfully, technologies evolve over the years. Accordingly, Microsoft has introduced ASP.NET MVC as an alternative to classic ASP.NET. I have developed a new architecture which uses many of the design principles of this article for this newer platform called S#arp Architecture.

Although this article is still the recommended background reading material for S#arp Architecture, you'll find the new architecture to be simpler and more maintainable while still leveraging the best of what NHibernate has to offer. Preface to the 1.2nd Edition In March of 2006 I published my initial thoughts on NHibernate best practices with ASP.NET, generics and unit tests. Quite simply, NHibernate is awesome. A quick thanks goes out to those who have implemented my ideas in their own work and have given plenty of ideas for improvement and consideration! Article Contents Introduction Why Use an ORM? Goals and Overview of Article.

ObjectViews. NHibernate Best Practices with ASP.NET, 1.2nd Ed. - The Code Pro. Author's note added June 11, 2008 - Announcement of S#arp Architecture Thankfully, technologies evolve over the years. Accordingly, Microsoft has introduced ASP.NET MVC as an alternative to classic ASP.NET. I have developed a new architecture which uses many of the design principles of this article for this newer platform called S#arp Architecture.

Although this article is still the recommended background reading material for S#arp Architecture, you'll find the new architecture to be simpler and more maintainable while still leveraging the best of what NHibernate has to offer. Preface to the 1.2nd Edition In March of 2006 I published my initial thoughts on NHibernate best practices with ASP.NET, generics and unit tests. Quite simply, NHibernate is awesome. A quick thanks goes out to those who have implemented my ideas in their own work and have given plenty of ideas for improvement and consideration! Article Contents Introduction Why Use an ORM?

Goals and Overview of Article. Mini-Guide: NHibernate.