KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ibatis > jpetstore > persistence > sqlmapdao > OrderSqlMapDao


1 /**
2  * User: Clinton Begin
3  * Date: Jul 13, 2003
4  * Time: 7:20:47 PM
5  */

6 package com.ibatis.jpetstore.persistence.sqlmapdao;
7
8 import com.ibatis.dao.client.DaoManager;
9 import com.ibatis.jpetstore.domain.LineItem;
10 import com.ibatis.jpetstore.domain.Order;
11 import com.ibatis.jpetstore.persistence.iface.OrderDao;
12 import com.ibatis.common.util.PaginatedList;
13
14 public class OrderSqlMapDao extends BaseSqlMapDao implements OrderDao {
15
16   public OrderSqlMapDao(DaoManager daoManager) {
17     super(daoManager);
18   }
19
20   public PaginatedList getOrdersByUsername(String JavaDoc username) {
21     return queryForPaginatedList("getOrdersByUsername", username, 10);
22   }
23
24   public Order getOrder(int orderId) {
25     Order order = null;
26     Object JavaDoc parameterObject = new Integer JavaDoc(orderId);
27     order = (Order) queryForObject("getOrder", parameterObject);
28     order.setLineItems(queryForList("getLineItemsByOrderId", new Integer JavaDoc(order.getOrderId())));
29     return order;
30   }
31
32   public void insertOrder(Order order) {
33     update("insertOrder", order);
34     update("insertOrderStatus", order);
35     for (int i = 0; i < order.getLineItems().size(); i++) {
36       LineItem lineItem = (LineItem) order.getLineItems().get(i);
37       lineItem.setOrderId(order.getOrderId());
38       update("insertLineItem", lineItem);
39     }
40
41   }
42
43 }
44
Popular Tags