Accessing an External Relational Database from JADE

You can access the relational database using the JADE language and by navigating relationships using inverse references; for example, you can code the following style of iterative access.

foreach emp in dept.employees do
    emp.display;
endforeach;

This code uses the external iterator and an external collection. The external collection issues the required SQL query to create a virtual collection of instances; that is, the rows of the employee table, where employee.dept_id = department.dept_id. The dept_id foreign key is obtained from the virtual department instance, which is the parent of the virtual employee dictionary.

The ExternalIterator class implements the standard iterator protocol; that is, the next and back methods, and so on.

The external iterator and external collections enable constructs like the foreach instruction to function in a transparent fashion.