Join-mapping to load data from multiple tables

Components address a situation where multiple domain classes need to be mapped to a single database table. If you have the exact opposite situation, where a single domain entity needs to be mapped to multiple database tables, then you can use joins. This feature comes with a caveat though—the tables being joined must have a one-to-one relation between them. You would soon agree that this caveat makes sense.

To understand this better, we would assume that in our employee benefits domain model, we do not have an Address entity, and all address fields are present on the Employee entity itself. Moreover, we would also assume that in the database, address fields are stored in a different table named Address, ...

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.