About Exposing View Links to Entity Objects

JDeveloper makes it possible for you to use the relationships defined by View Links to better define the results obtained while traversing Entity Objects. JDeveloper does this by letting you create a method inside an Entity Object that provides easy access to data returned by the View Link. This feature has these advantages:

The View Link makes it easy to write business logic which traverses from one object to a related object. The View Objects which comprise the View Link allow arbitrary PL/SQL statements. These statements can enable complex filtering and restriction of related datasets. Exposing the View Link as an Entity Accessor means that you can further enhance your business logic programming model with prebuilt "finders" that find related collections of more interestingly qualified pieces of dependent data.

The accessor can only exist on the Entity Object which corresponds to the selected attributes in the source View Object. Like View Links, the accessor is unidirectional: the accessor works with data in the detail View Object.

What Gets Returned?

The accessor on the Entity Object passes parameters into a new View Object which it instantiates. The data in the View Object is whatever data is defined by the Entity Object row, the specified View Link, and View Object.

For example, assume you have created the Dept and Emp Entity Objects and their corresponding View Objects. The Dept Entity Object has three rows, corresponding to department numbers (Deptno) 10, 20, and 30. In the Emp Entity Object, all terminated employees have their employee ID (Empno) set to -1. Assume also that a View Link, DeptToEmpVL, has been defined from Dept as the source, to Emp on the Deptno attribute. In this case, the Dept Entity Object can instantiate a View Object containing employee data corresponding to department 10. It can also instantiate a View Object containing employee data corresponding to department 20, and so on.

You can define an accessor in the Dept Entity, getTerminatedEmps, that will return the records of employees whose Empno is less than 0. This accessor works by searching the View Object containing employee data corresponding to a specified department number. The accessor will return an iterator into the records that match Empno<0 for the current Dept row.

Working with Multiple Levels of Detail

As described above, the accessor on the Entity Object can traverse the View Link to use data returned by the destination View Object. If you have multiple levels of detail in your Application Module, once you get the View Object ResultSet, you are free to use any of the data that it returns.