01: /**
02: * User: Clinton Begin Date: Jul 13, 2003 Time: 7:20:47 PM
03: */package com.ibatis.jpetstore.persistence.sqlmapdao;
04:
05: import com.ibatis.common.util.PaginatedList;
06: import com.ibatis.dao.client.DaoManager;
07: import com.ibatis.jpetstore.domain.LineItem;
08: import com.ibatis.jpetstore.domain.Order;
09: import com.ibatis.jpetstore.persistence.iface.OrderDao;
10:
11: public class OrderSqlMapDao extends BaseSqlMapDao implements OrderDao {
12:
13: public OrderSqlMapDao(DaoManager daoManager) {
14: super (daoManager);
15: }
16:
17: public PaginatedList getOrdersByUsername(String username) {
18: return queryForPaginatedList("getOrdersByUsername", username,
19: 10);
20: }
21:
22: public Order getOrder(int orderId) {
23: Order order = null;
24: Object parameterObject = new Integer(orderId);
25: order = (Order) queryForObject("getOrder", parameterObject);
26: order.setLineItems(queryForList("getLineItemsByOrderId",
27: new Integer(order.getOrderId())));
28: return order;
29: }
30:
31: public void insertOrder(Order order) {
32: update("insertOrder", order);
33: update("insertOrderStatus", order);
34: for (int i = 0; i < order.getLineItems().size(); i++) {
35: LineItem lineItem = (LineItem) order.getLineItems().get(i);
36: lineItem.setOrderId(order.getOrderId());
37: update("insertLineItem", lineItem);
38: }
39:
40: }
41:
42: }
|