Rogue Wave Server/Rogue Wave Views Integration > Server/Views Mapping > Multiple-Row-Type Tables > Managing Inheritance Using Multiple-Row-Type Tables
 
Managing Inheritance Using Multiple-Row-Type Tables
Multiple-row-type tables can be useful when you want to represent objects of different types from the same relation if this relation contains both instances of a given class and instances of a subclass.
For example, assuming that the employees relation in a Department object contains both Employee objects and Executive objects, you may want to store objects of both types in the same table. Instructions to create such a table in Rogue Wave Server Studio are provided in Rogue Wave Server Studio Advanced Features.
The following view specification will be generated:
subscribe origin Department:
represent IlsSwTable AllEmployeeTable:
string column[1]="name";
string column[2]="hireDate";
string column[3]="monthCost";
string column[4]="title";
Collector rows=employees->employeeRow;
string rowType="Employee,employeeRow";
string collectorName="rows";
propagate employees;
subscribe Employee:
represent IlsSwRow employeeRow
## draggedPath=employees.Executive:
mandatory Ref<IlsSwTable> table=view.origin->AllEmployeeTable;
string column[1]=name;
int column[2]=hireDate;
int column[3]=monthCost;
subscribe Executive:
represent IlsSwRow executiveRow
## draggedPath=employees.Executive:
mandatory Ref<IlsSwTable> table=view.origin->AllEmployeeTable;
string column[1]=name;
int column[2]=hireDate;
int column[3]=monthCost;
string column[4]=title;
This code sample can be illustrated as follows:
Figure 13.4    Multiple-Row-Type Table for Inheritance
Whereas the class Executive inherits from the class Employee in the server object model, the instances of these classes are represented by two different row types stored in the same table. Instances of the class Executive execute the represent clause for the class Executive and only that one while instances of the class Employee execute the represent clause for the class Employee. In such a view specification, title is an attribute of the Executive class. This attribute is left blank for instances that are not of the type Executive.
Note: As usual, the table schema must be shared by all rows that reference this table.
You can explicitly create instances of the Executive server type by using the rowType table property and add them to the employees relation via the collector. When an executiveRow representation object is deleted, Rogue Wave Server will not be able to find a matching collector. It will therefore use the default collector and remove the Executive object from the employees relation.

Version 5.8
Copyright © 2014, Rogue Wave Software, Inc. All Rights Reserved.