architect-handbook

Software Architect Handbook

View on GitHub

Dependent Mapping

Has one class perform the database mapping for a child class.

Overview

Some objects naturally appear in the context of other objects.

Tracks on an album may be loaded or saved whenever the underlying album is loaded or saved.

If they aren’t referenced to by any other table in the database, you can simplify the mapping procedure by having the one class mapper perform the mapping for other class aswell (e.g. album warpper perform the mapping for the tracks too), treating this mapping as a dependent mapping.

How It Works

The basic idea is that one class (the dependent) relies upon some other class (the owner) for its database persistence.

When to Use It