Modeling Vertical Inheritance

Continuing with the example used for single table mapping, let's re-map it as vertical inheritance.

Note that in Cayenne vertical is essentially single table with flattened attributes in subclasses. We'll demonstrate this below.

We need to start by mapping all 3 tables, and creating 1..1 relationship between BOOK and subclass tables ("To Dep PK" must be checked on BOOK side of relationships).

On the ObjEntity end, there is no difference in mapping qualifier (it is needed), superclass, root table ("Table/View" for subclasses is still "BOOK"). The only difference is that subclass-specific attributes are mapped as "flattened attributes":

Note that flattened attributes can be used with or without inheritance, however in combination with single-table inheritance mapping, they give us "vertical" inheritance.