Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This is great for reading entities from a single table but clients often need to read data from related tables for example Customers and their related Orders. The RDB DAS can work with related database tables and reads that span tables produce graphs of related data objects. Continuing with our Customer->Order example, a client can read a set of Customers and related Orders by using a SELECT statement that includes a join as in the following example:

Code Blockpanel

DAS

das

=

DAS.FACTORY.createDAS(getConfig("CustomerOrderConfig.xml"),

getConnection());


//

Read

some

customers

and

related

orders


Command

select

=

das.createCommand("SELECT

*

FROM

CUSTOMER

LEFT

JOIN

ANORDER

ON

CUSTOMER.ID

=

ANORDER.CUSTOMER_ID

WHERE

CUSTOMER.ID

=

1");

Wiki Markup
 DataObject root = select.executeQuery();

 DataObject customer = root.getDataObject("CUSTOMER\[1\]");
 

List orders = customer.getList("orders");

You can see that the client can work with the data graph as a set of related objects. Once the application has a handle to a customer, it can reference that customers related orders by accessing the customers "orders" property.

...