Mapping

About the mapping of object hierarchies to relational databases
Article series on NHibernate and Fluent NHibernate – Part 3

Today the third part of my series on NHibernate and Fluent NHibernate went live. It took a little bit longer due to work overload. You can read it here. Summary In part 3 of this article series about NHibernate and Fluent NHibernate I have discussed how to let Fluent NHibernate automatically map a domain model to a data model. We have realized that FNH provides a reasonable mapping out of the box by using default conventions. I have shown how one can implement user defined conventions which will influence how the mapping is defined on a very fine...

posted @ Tuesday, September 01, 2009 4:51 PM | Feedback (970)

Article series on NHibernate and Fluent NHibernate – Part 2

Today the second part of my series on NHibernate and Fluent NHibernate went live. You can read it here. Summary In part 2 of the article series I have continued to implement the remaining part of the domain which I had introduced in the first part. I discuss the mapping of various forms of relations between different entities. For all mappings I have presented the code needed to verify the mappings. In part 3 of the article series I’ll show how one can further refactor and improve the mapping of the domain model. I’ll then discuss the usage of conventions and...

posted @ Thursday, April 16, 2009 12:30 AM | Feedback (892)

Article series on NHibernate and Fluent NHibernate

Sorry for having been quiet such a long time. But I was really busy lately. I wrote several articles for journals and other non NHibernate related posts. But now the good news for all of you who like my tutorial like posts... I have been invited to write a series of articles on NHibernate and Fluent NHibernate on http://dotnetslackers.com. The first part of this series has just been published. I invite you to read it here. In this series I start from grounds up and will explain to the readers how easy it has become to write an NHibernate based application...

posted @ Wednesday, April 08, 2009 12:04 PM | Feedback (597)

Linq to NHibernate

The popularity of NHibernate is steadily increasing. At the same time people get used to LINQ. Now there exists a LINQ to NHibernate provider since quite some time. It's not a complete implementation of a LINQ provider but it is still quite useful. Most of the day to day problems we face when developing typical business application can be solved by using this provider. And if there is a query that cannot be executed against the provider we still have the option to falling back to the hibernate query language (HQL). In this post I'll give you...

posted @ Wednesday, November 26, 2008 5:13 AM | Feedback (813)

Lazy loading BLOBS and the like in NHibernate

[Updated, 2008-11-20 --> see end of post] One of the questions that is asked again and again in the NHibernate user mailing list is the question about whether NHibernate supports lazy-loading of properties. The answer is NO - at least for the time being. Why is this question reasonable? Well, often we have entities in our domain that contain fields with large amount of data. Some samples are a large binary object (BLOB, e.g. an image, a Word document, a PDF, etc.), a large text object (CLOB, or nvarchar(max) )...

posted @ Monday, November 17, 2008 12:23 AM | Feedback (727)

A fluent interface to NHibernate - Part 4 - Configuration

This is the fourth post in a series of articles where I want to analyze and describe the new upcoming mapping interface providing a fluent interface to NHibernate for the mapping of a domain model to the underlying database. The previous post are A fluent interface to NHibernate A fluent interface to NHibernate - Part 2 - Value Objects A fluent interface to NHibernate - Part 3 - Mapping Relations Configuration In NHibernate we traditionally had several methods how we could configure the database relevant parameters. These...

posted @ Monday, August 25, 2008 7:07 PM | Feedback (449)

A fluent interface to NHibernate - Part 3 - Mapping Relations

This is the third post in a series of articles where I want to analyze and describe the new upcoming mapping interface providing a fluent interface to NHibernate for the mapping of a domain model to the underlying database. The other posts are A fluent interface to NHibernate A fluent interface to NHibernate - Part 2 - Value Objects A fluent interface to NHibernate - Part 4 - Configuration You can get the source code of the solution accompanying this post here. In the time...

posted @ Friday, August 15, 2008 1:36 AM | Feedback (411)

A fluent interface to NHibernate

Do you like NHibernate? Do you like XML? My answer would be yes for the former and no for the latter. But if you want to map your entities to the underlying database tables you have no other choice than use XML. Ok, you are right, we still have the possibility to use attributes for the mapping (e.g. by using Castle Active Record) but in this case we are "polluting" our nice domain objects with infrastructure related information which definitely does NOT belong into the domain model. Here comes our salvation. We now have a third player in the...

posted @ Monday, August 11, 2008 10:26 AM | Feedback (694)

How to map a tree in NHibernate

Introduction Lately there have been many questions regarding how to best map a tree structure in NHibernate. In this post I'll try to show you various techniques how one can deal with a tree structure. The code for this sample you can get from here. Domain Model Let's define a very simple domain model for this sample. We have a single class called Equipment that has a parent of type Equipment and 0 to many children of type Equipment. The tree has a single root node. The root node is specific by the fact that it's...

posted @ Wednesday, May 14, 2008 10:19 AM | Feedback (449)

Create and Update Database Schema

Introduction When developing an application using DDD one starts by trying to define a model of the domain for/in which the application should be used. At the same time you try to establish the so called ubiquitous language. At some point you might need to store and or retrieve data into or from a data source. Very often this data source is a relational database. But it's not necessarily always the case. It could as well be a web service or a XML document. That leads me to the notion that "the database is just an implementation detail of...

posted @ Monday, April 28, 2008 9:52 AM | Feedback (748)

NHibernate and Castle Active Record (Part 1)

Introduction The Castle ActiveRecord project is an implementation of the ActiveRecord pattern for .NET. The ActiveRecord pattern consists on instance properties representing a record in the database, instance methods acting on that specific record and static methods acting on all records. Castle ActiveRecord is built on top of NHibernate, but its attribute-based mapping free the developer of writing XML for database-to-object mapping, which is needed when using NHibernate directly. You can find the home page of the Castle project here. How will we use it? My intent is not to implement the ActiveRecord pattern...

posted @ Saturday, April 26, 2008 7:33 AM | Feedback (530)