Java Reference
In-Depth Information
private PendingOrderDTO
findPendingOrder(String pendingOrderId) {
PendingOrderDTO pendingOrderDTO =
(PendingOrderDTO)
getSqlMapClientTemplate()
.queryForObject(
"findPendingOrder",
pendingOrderId);
return pendingOrderDTO;
}
}
In this method, the constructor takes a SQLMapClientTemplate as a parameter and
calls the setter defined by SqlMapClientDaoSupport . The findPendingOrder()
method uses SqlMapClientTemplate to execute the SQL SELECT statements that load
the PendingOrder , its line items, its restaurant, and its restaurant's menu items.
This method is extremely simple because i BATIS does all of the work. Let's
look at how it is configured.
Executes query
Writing the iBATIS SQL maps
After writing a DAO method, the next step is to write the i BATIS mapped state-
ments that are executed by the DAO to query and update the database. The
mapped statement that is executed by the findPendingOrder() must retrieve not
only the pending order but also its line items, its restaurant, and the restaurant's
menu items. One straightforward way to accomplish this is to configure i BATIS to
execute the following SQL statements:
select *
from PENDING_ORDER o, RESTAURANT r
where
o.pending_order_id = ?
AND r.restaurant_id (+)= o.restaurant_id
select *
from PENDING_ORDER_LINE_ITEM l, MENU_ITEM mi
where
l.pending_order_id = ?
AND mi.menu_item_id = l.menu_item_id
select *
from MENU_ITEM mi
where mi.restaurant_id = ?
Search WWH ::




Custom Search