Inheritance is a powerful feature of object-oriented development that can simplify development and maintenance when used appropriately.
Example2:
Your application's database schema might contain tables where different logical kinds of business information are stored in rows of the same table, These tables will typically have one column whose value determines the kind of information stored in each row.
Example1:
Table Persons contains PERSON_TYPE_CODE column whose value are STAFF, CUST, or SUPP that column determines what kind of PERSON the row represents.
Example2:
Table Departments contains DEPT_TYPE column whose value are Small or Big, that column determines the size of each department.
To implement Example2 you need to have table Departments in your DB, then at Oracle JDeveloper
Create three entities following by a view for each and put them in your Application Module:
1- Departments - The master entity.
3- Small Departments - The second child Entity
After creating the entity select Discriminator Property checkbox at the DeptType Entity Attribute,
2- BigDepartments - The Child Entity:
Click The Button Browse at "Extends Entity" to select the master created Entity Departments,
then click the "next" button
Click the button "override"
Choose to override the DeptType attribute at the BigDepartments Entity,
then click "Ok" then "Next" button
Make sure that the "Discriminator" Checkbox for DeptType is cheked and readonly,
and type the value for the discriminator for this entity,let it be big,
then click Next till end
3- Small Departments - The second child Entity
Follow the same steps as BigDepartments Entity
Result:
Record that has value of DeptType attribute equal to big will exist at the BigDepartmentsView.
Note:
- Leaving the discriminator value (at the parent entity) empty means that the view object "DepartmentsView" will bring records that has DeptType value equals to null,
- If you want to bring all records at the "DepartmentsView" you need to select other views as subtype to the Departmentsview.
You can download my sample application from this link
The Application contains a method Print() at Department Entity Implementation Class and each child entity overrides it and you can put different business code for each type.