Components

We have seen components in Chapter 3, Let's Tell NHibernate About Our Database. We had seen that ResidentialAddress property on Employee class can be mapped as a component or as a one-to-one relation. When it is mapped as a component, all properties on the Address class are assumed to be present in the Employee table, while you get the freedom to use a separate class to represent an address. With one-to-one mapping, the Address class is mapped to its own table.

It is possible that the database that you are working with has modeled such instances in one of the two ways. If you want to model a domain concept using its own class, but state information in that class is not kept in its own table, then you can use components.

Since we covered ...

Get Learning NHibernate 4 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.