Java Reference
In-Depth Information
Let's look at the details of the top-level mapped statement and its result map:
B
The findPendingOrder mapped statement defines the SQL SELECT statement that
retrieves the pending order and its restaurant. The pending order is specified by a
String parameter and the result is constructed using the PendingOrderResultMap
result map.
C
The PendingOrderResultMap result map specifies the mapping between the prop-
erties of the PendingOrderDTO and RestaurantDTO beans and columns of the result
set returned by the query that finds the pending order.
The result map also specifies that the line items and the restaurant's menu items
should be retrieved using other nested mapped statements.
The findLineItems mapped statement defines the SELECT statement that retrieves
the pending order's line items.
The PendingOrderLineItemResultMap result map is used by the findLineItems
mapped statement to create the PendingOrderLineItemDTO s.
The findMenuItems mapped statement defines the SELECT statement that retrieves
the restaurant's menu items.
The MenuItemResultMap result map is used by the findMenuItems mapped state-
ment to create the MenuItemDTO s.
The details of other <select> statements and <resultMap> definitions are similar.
D
E
F
G
H
Testing iBATIS maps
The final step in the process of implementing a DAO is to write tests for the i BATIS
maps and the SQL statements. Because i BATIS replaces potentially complex DAO s
with simple DAO s and XML mapping files, testing the DAO s can be extremely
straightforward and can be accomplished with mock objects. However, it is also
important to write tests for the i BATIS maps and SQL statements because they imple-
ment a lot of functionality. These tests must verify the correctness of three things:
The i BATIS statements, which specify how object properties map to SQL
statement parameters
The SQL statements, which query and update the database
The iB ATIS result maps, which specify how database columns map to object
properties
There are a variety of approaches that you can use to test the i BATIS maps and SQL
statements. The most thorough approach is to write to one or more tests for each
 
Search WWH ::




Custom Search