Chapter 6. Advanced mapping concepts
This chapter covers
- The NHibernate type system
- Custom mapping types
- Collection mappings
- One-to-one and many-to-many associations
In chapter 3, we introduced the most important ORM features provided by NHibernate, including basic class and property mappings, inheritance mappings, component mappings, and one-to-many association mappings. We now extend these topics by turning to the more exotic collection and association mappings that allow you to handle trickier use cases. It’s worth noting that these more exotic mappings should only be used with careful consideration; it’s possible to implement any domain model using simpler component mappings (one-to-many associations and one-to-one associations). Throughout this chapter, we advise you about when you may or may not want to use the advanced features as they’re discussed.
Some of these features require you to have a more in-depth understanding of NHibernate’s type system, particularly the distinction between entity and value types. That is where we begin.
We first distinguished between entity and value types back in section 3.6.1. In order to give you a better understanding of the NHibernate type system, we elaborate a little more.