You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ibatis.apache.org by cb...@apache.org on 2005/12/06 07:42:07 UTC

svn commit: r354337 [2/9] - in /ibatis/trunk/java/jpetstore/jpetstore5: ./ build/ devlib/ doc/ lib/ src/ src/com/ src/com/ibatis/ src/com/ibatis/jpetstore/ src/com/ibatis/jpetstore/domain/ src/com/ibatis/jpetstore/persistence/ src/com/ibatis/jpetstore/...

Added: ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/ItemSqlMapDao.java
URL: http://svn.apache.org/viewcvs/ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/ItemSqlMapDao.java?rev=354337&view=auto
==============================================================================
--- ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/ItemSqlMapDao.java (added)
+++ ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/ItemSqlMapDao.java Mon Dec  5 22:39:31 2005
@@ -0,0 +1,47 @@
+package com.ibatis.jpetstore.persistence.sqlmapdao;
+
+import com.ibatis.common.util.PaginatedList;
+import com.ibatis.dao.client.DaoManager;
+import com.ibatis.jpetstore.domain.Item;
+import com.ibatis.jpetstore.domain.LineItem;
+import com.ibatis.jpetstore.domain.Order;
+import com.ibatis.jpetstore.persistence.iface.ItemDao;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class ItemSqlMapDao extends BaseSqlMapDao implements ItemDao {
+
+  public ItemSqlMapDao(DaoManager daoManager) {
+    super(daoManager);
+  }
+
+  public void updateAllQuantitiesFromOrder(Order order) {
+    for (int i = 0; i < order.getLineItems().size(); i++) {
+      LineItem lineItem = (LineItem) order.getLineItems().get(i);
+      String itemId = lineItem.getItemId();
+      Integer increment = new Integer(lineItem.getQuantity());
+      Map param = new HashMap(2);
+      param.put("itemId", itemId);
+      param.put("increment", increment);
+      update("updateInventoryQuantity", param);
+    }
+  }
+
+  public boolean isItemInStock(String itemId) {
+    Integer i = (Integer) queryForObject("getInventoryQuantity", itemId);
+    return (i != null && i.intValue() > 0);
+  }
+
+  public PaginatedList getItemListByProduct(String productId) {
+    return queryForPaginatedList("getItemListByProduct", productId, PAGE_SIZE);
+  }
+
+  public Item getItem(String itemId) {
+    Integer i = (Integer) queryForObject("getInventoryQuantity", itemId);
+    Item item = (Item) queryForObject("getItem", itemId);
+    item.setQuantity(i.intValue());
+    return item;
+  }
+
+}

Added: ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/OrderSqlMapDao.java
URL: http://svn.apache.org/viewcvs/ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/OrderSqlMapDao.java?rev=354337&view=auto
==============================================================================
--- ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/OrderSqlMapDao.java (added)
+++ ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/OrderSqlMapDao.java Mon Dec  5 22:39:31 2005
@@ -0,0 +1,37 @@
+package com.ibatis.jpetstore.persistence.sqlmapdao;
+
+import com.ibatis.dao.client.DaoManager;
+import com.ibatis.jpetstore.domain.LineItem;
+import com.ibatis.jpetstore.domain.Order;
+import com.ibatis.jpetstore.persistence.iface.OrderDao;
+import com.ibatis.common.util.PaginatedList;
+
+public class OrderSqlMapDao extends BaseSqlMapDao implements OrderDao {
+
+  public OrderSqlMapDao(DaoManager daoManager) {
+    super(daoManager);
+  }
+
+  public PaginatedList getOrdersByUsername(String username) {
+    return queryForPaginatedList("getOrdersByUsername", username, 10);
+  }
+
+  public Order getOrder(int orderId) {
+    Order order = null;
+    Object parameterObject = new Integer(orderId);
+    order = (Order) queryForObject("getOrder", parameterObject);
+    order.setLineItems(queryForList("getLineItemsByOrderId", new Integer(order.getOrderId())));
+    return order;
+  }
+
+  public void insertOrder(Order order) {
+    insert("insertOrder", order);
+    insert("insertOrderStatus", order);
+    for (int i = 0; i < order.getLineItems().size(); i++) {
+      LineItem lineItem = (LineItem) order.getLineItems().get(i);
+      lineItem.setOrderId(order.getOrderId());
+      insert("insertLineItem", lineItem);
+    }
+  }
+
+}

Added: ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/ProductSqlMapDao.java
URL: http://svn.apache.org/viewcvs/ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/ProductSqlMapDao.java?rev=354337&view=auto
==============================================================================
--- ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/ProductSqlMapDao.java (added)
+++ ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/ProductSqlMapDao.java Mon Dec  5 22:39:31 2005
@@ -0,0 +1,48 @@
+package com.ibatis.jpetstore.persistence.sqlmapdao;
+
+import com.ibatis.common.util.PaginatedList;
+import com.ibatis.dao.client.DaoManager;
+import com.ibatis.jpetstore.domain.Product;
+import com.ibatis.jpetstore.persistence.iface.ProductDao;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+public class ProductSqlMapDao extends BaseSqlMapDao implements ProductDao {
+
+  public ProductSqlMapDao(DaoManager daoManager) {
+    super(daoManager);
+  }
+
+  public PaginatedList getProductListByCategory(String categoryId) {
+    return queryForPaginatedList("getProductListByCategory", categoryId, PAGE_SIZE);
+  }
+
+  public Product getProduct(String productId) {
+    return (Product) queryForObject("getProduct", productId);
+  }
+
+  public PaginatedList searchProductList(String keywords) {
+    Object parameterObject = new ProductSearch(keywords);
+    return queryForPaginatedList("searchProductList", parameterObject, PAGE_SIZE);
+  }
+
+  /* Inner Classes */
+
+  public static class ProductSearch {
+    private List keywordList = new ArrayList();
+
+    public ProductSearch(String keywords) {
+      StringTokenizer splitter = new StringTokenizer(keywords, " ", false);
+      while (splitter.hasMoreTokens()) {
+        keywordList.add("%" + splitter.nextToken() + "%");
+      }
+    }
+
+    public List getKeywordList() {
+      return keywordList;
+    }
+  }
+
+}

Added: ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/SequenceSqlMapDao.java
URL: http://svn.apache.org/viewcvs/ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/SequenceSqlMapDao.java?rev=354337&view=auto
==============================================================================
--- ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/SequenceSqlMapDao.java (added)
+++ ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/SequenceSqlMapDao.java Mon Dec  5 22:39:31 2005
@@ -0,0 +1,37 @@
+package com.ibatis.jpetstore.persistence.sqlmapdao;
+
+import com.ibatis.dao.client.DaoException;
+import com.ibatis.dao.client.DaoManager;
+import com.ibatis.jpetstore.domain.Sequence;
+import com.ibatis.jpetstore.persistence.iface.SequenceDao;
+
+public class SequenceSqlMapDao extends BaseSqlMapDao implements SequenceDao {
+
+  public SequenceSqlMapDao(DaoManager daoManager) {
+    super(daoManager);
+  }
+
+  /**
+   * This is a generic sequence ID generator that is based on a database
+   * table called 'SEQUENCE', which contains two columns (NAME, NEXTID).
+   * <p/>
+   * This approach should work with any database.
+   *
+   * @param name The name of the sequence.
+   * @return The Next ID
+   * @
+   */
+  public synchronized int getNextId(String name) {
+    Sequence sequence = new Sequence(name, -1);
+
+    sequence = (Sequence) queryForObject("getSequence", sequence);
+    if (sequence == null) {
+      throw new DaoException("Error: A null sequence was returned from the database (could not get next " + name + " sequence).");
+    }
+    Object parameterObject = new Sequence(name, sequence.getNextId() + 1);
+    update("updateSequence", parameterObject);
+
+    return sequence.getNextId();
+  }
+
+}

Added: ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/sql/Account.xml
URL: http://svn.apache.org/viewcvs/ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/sql/Account.xml?rev=354337&view=auto
==============================================================================
--- ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/sql/Account.xml (added)
+++ ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/sql/Account.xml Mon Dec  5 22:39:31 2005
@@ -0,0 +1,110 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
+    "http://ibatis.apache.org/dtd/sql-map-2.dtd">
+
+<sqlMap namespace="Account">
+
+  <typeAlias alias="account" type="com.ibatis.jpetstore.domain.Account"/>
+
+  <select id="getAccountByUsername" resultClass="account" parameterClass="string">
+    SELECT
+          SIGNON.USERNAME,
+          ACCOUNT.EMAIL,
+          ACCOUNT.FIRSTNAME,
+          ACCOUNT.LASTNAME,
+          ACCOUNT.STATUS,
+          ACCOUNT.ADDR1 AS address1,
+          ACCOUNT.ADDR2 AS address2,
+          ACCOUNT.CITY,
+          ACCOUNT.STATE,
+          ACCOUNT.ZIP,
+          ACCOUNT.COUNTRY,
+          ACCOUNT.PHONE,
+          PROFILE.LANGPREF AS languagePreference,
+          PROFILE.FAVCATEGORY AS favouriteCategoryId,
+          PROFILE.MYLISTOPT AS listOption,
+          PROFILE.BANNEROPT AS bannerOption,
+          BANNERDATA.BANNERNAME
+    FROM ACCOUNT, PROFILE, SIGNON, BANNERDATA
+    WHERE ACCOUNT.USERID = #username#
+      AND SIGNON.USERNAME = ACCOUNT.USERID
+      AND PROFILE.USERID = ACCOUNT.USERID
+      AND PROFILE.FAVCATEGORY = BANNERDATA.FAVCATEGORY
+  </select>
+
+  <select id="getAccountByUsernameAndPassword" resultClass="account" parameterClass="account">
+    SELECT
+      SIGNON.USERNAME,
+      ACCOUNT.EMAIL,
+      ACCOUNT.FIRSTNAME,
+      ACCOUNT.LASTNAME,
+      ACCOUNT.STATUS,
+      ACCOUNT.ADDR1 AS address1,
+      ACCOUNT.ADDR2 AS address2,
+      ACCOUNT.CITY,
+      ACCOUNT.STATE,
+      ACCOUNT.ZIP,
+      ACCOUNT.COUNTRY,
+      ACCOUNT.PHONE,
+      PROFILE.LANGPREF AS languagePreference,
+      PROFILE.FAVCATEGORY AS favouriteCategoryId,
+      PROFILE.MYLISTOPT AS listOption,
+      PROFILE.BANNEROPT AS bannerOption,
+      BANNERDATA.BANNERNAME
+    FROM ACCOUNT, PROFILE, SIGNON, BANNERDATA
+    WHERE ACCOUNT.USERID = #username#
+      AND SIGNON.PASSWORD = #password#
+      AND SIGNON.USERNAME = ACCOUNT.USERID
+      AND PROFILE.USERID = ACCOUNT.USERID
+      AND PROFILE.FAVCATEGORY = BANNERDATA.FAVCATEGORY
+  </select>
+
+  <update id="updateAccount" parameterClass="account">
+    UPDATE ACCOUNT SET
+      EMAIL = #email#,
+      FIRSTNAME = #firstName#,
+      LASTNAME = #lastName#,
+      STATUS = #status#,
+      ADDR1 = #address1#,
+      ADDR2 = #address2:VARCHAR#,
+      CITY = #city#,
+      STATE = #state#,
+      ZIP = #zip#,
+      COUNTRY = #country#,
+      PHONE = #phone#
+    WHERE USERID = #username#
+  </update>
+
+  <insert id="insertAccount" parameterClass="account">
+    INSERT INTO ACCOUNT
+      (EMAIL, FIRSTNAME, LASTNAME, STATUS, ADDR1, ADDR2, CITY, STATE, ZIP, COUNTRY, PHONE, USERID)
+    VALUES
+      (#email#, #firstName#, #lastName#, #status#, #address1#,  #address2:VARCHAR#, #city#, #state#, #zip#, #country#, #phone#, #username#)
+  </insert>
+
+  <update id="updateProfile" parameterClass="account">
+    UPDATE PROFILE SET
+      LANGPREF = #languagePreference#,
+      FAVCATEGORY = #favouriteCategoryId#,
+      MYLISTOPT = #listOption#,
+      BANNEROPT = #bannerOption#
+    WHERE USERID = #username#
+  </update>
+
+  <insert id="insertProfile" parameterClass="account">
+    INSERT INTO PROFILE (LANGPREF, FAVCATEGORY, MYLISTOPT, BANNEROPT, USERID)
+    VALUES (#languagePreference#, #favouriteCategoryId#, #listOption#, #bannerOption#, #username#)
+  </insert>
+
+  <update id="updateSignon" parameterClass="account">
+    UPDATE SIGNON SET PASSWORD = #password#
+    WHERE USERNAME = #username#
+  </update>
+
+  <insert id="insertSignon" parameterClass="account">
+    INSERT INTO SIGNON (PASSWORD,USERNAME)
+    VALUES (#password#, #username#)
+  </insert>
+
+</sqlMap>

Added: ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/sql/Category.xml
URL: http://svn.apache.org/viewcvs/ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/sql/Category.xml?rev=354337&view=auto
==============================================================================
--- ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/sql/Category.xml (added)
+++ ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/sql/Category.xml Mon Dec  5 22:39:31 2005
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
+    "http://ibatis.apache.org/dtd/sql-map-2.dtd">
+
+<sqlMap namespace="Category">
+
+  <typeAlias alias="category" type="com.ibatis.jpetstore.domain.Category"/>
+
+  <cacheModel id="categoryCache" type="LRU">
+    <flushInterval hours="24"/>
+    <property name="size" value="100"/>
+  </cacheModel>
+
+  <resultMap id="categoryResult" class="category">
+    <result property="categoryId" column="CATID"/>
+    <result property="name" column="NAME"/>
+    <result property="description" column="DESCN"/>
+  </resultMap>
+
+  <select id="getCategory" resultClass="category" parameterClass="string" cacheModel="categoryCache">
+    SELECT
+      CATID AS categoryId,
+      NAME,
+      DESCN AS description
+    FROM CATEGORY
+    WHERE CATID = #categoryId#
+  </select>
+
+  <select id="getCategoryList" resultClass="category" cacheModel="categoryCache">
+    SELECT
+      CATID AS categoryId,
+      NAME,
+      DESCN AS description
+    FROM CATEGORY
+  </select>
+
+</sqlMap>

Added: ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/sql/Item.xml
URL: http://svn.apache.org/viewcvs/ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/sql/Item.xml?rev=354337&view=auto
==============================================================================
--- ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/sql/Item.xml (added)
+++ ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/sql/Item.xml Mon Dec  5 22:39:31 2005
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
+    "http://ibatis.apache.org/dtd/sql-map-2.dtd">
+
+<sqlMap namespace="Item">
+
+  <typeAlias alias="item" type="com.ibatis.jpetstore.domain.Item"/>
+
+  <cacheModel id="itemCache" type="LRU">
+    <flushInterval hours="24"/>
+    <property name="size" value="100"/>
+  </cacheModel>
+
+  <cacheModel id="quantityCache" type="LRU">
+    <flushInterval hours="24"/>
+    <flushOnExecute statement="updateInventoryQuantity"/>
+    <property name="size" value="100"/>
+  </cacheModel>
+
+  <select id="getItemListByProduct" resultClass="item" parameterClass="string" cacheModel="itemCache">
+    SELECT
+      ITEMID,
+      LISTPRICE,
+      UNITCOST,
+      SUPPLIER AS supplierId,
+      I.PRODUCTID AS "product.productId",
+      NAME AS "product.name",
+      DESCN AS "product.description",
+      CATEGORY AS "product.categoryId",
+      STATUS,
+      ATTR1 AS attribute1,
+      ATTR2 AS attribute2,
+      ATTR3 AS attribute3,
+      ATTR4 AS attribute4,
+      ATTR5 AS attribute5
+    FROM ITEM I, PRODUCT P
+    WHERE P.PRODUCTID = I.PRODUCTID
+    AND I.PRODUCTID = #value#
+  </select>
+
+  <select id="getItem" resultClass="item" parameterClass="string" cacheModel="quantityCache">
+    select
+      ITEMID,
+      LISTPRICE,
+      UNITCOST,
+      SUPPLIER AS supplierId,
+      I.PRODUCTID AS "product.productId",
+      NAME AS "product.name",
+      DESCN AS "product.description",
+      CATEGORY AS "product.categoryId",
+      STATUS,
+      ATTR1 AS attribute1,
+      ATTR2 AS attribute2,
+      ATTR3 AS attribute3,
+      ATTR4 AS attribute4,
+      ATTR5 AS attribute5,
+      QTY AS quantity
+    from ITEM I, INVENTORY V, PRODUCT P
+    where P.PRODUCTID = I.PRODUCTID
+      and I.ITEMID = V.ITEMID
+      and I.ITEMID = #value#
+  </select>
+
+  <select id="getInventoryQuantity" resultClass="int" parameterClass="string">
+    SELECT QTY AS value
+    FROM INVENTORY
+    WHERE ITEMID = #itemId#
+  </select>
+
+  <update id="updateInventoryQuantity" parameterClass="map">
+    UPDATE INVENTORY SET
+      QTY = QTY - #increment#
+    WHERE ITEMID = #itemId#
+  </update>
+
+</sqlMap>

Added: ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/sql/LineItem.xml
URL: http://svn.apache.org/viewcvs/ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/sql/LineItem.xml?rev=354337&view=auto
==============================================================================
--- ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/sql/LineItem.xml (added)
+++ ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/sql/LineItem.xml Mon Dec  5 22:39:31 2005
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
+    "http://ibatis.apache.org/dtd/sql-map-2.dtd">
+
+<sqlMap namespace="LineItem">
+
+  <typeAlias alias="lineItem" type="com.ibatis.jpetstore.domain.LineItem"/>
+
+  <select id="getLineItemsByOrderId" resultClass="lineItem" parameterClass="int">
+    SELECT
+      ORDERID,
+      LINENUM AS lineNumber,
+      ITEMID,
+      QUANTITY,
+      UNITPRICE
+    FROM LINEITEM
+    WHERE ORDERID = #orderId#
+  </select>
+
+  <insert id="insertLineItem" parameterClass="lineItem">
+    INSERT INTO LINEITEM (ORDERID, LINENUM, ITEMID, QUANTITY, UNITPRICE)
+    VALUES (#orderId#, #lineNumber#, #itemId#, #quantity#, #unitPrice#)
+  </insert>
+
+</sqlMap>

Added: ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/sql/Order.xml
URL: http://svn.apache.org/viewcvs/ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/sql/Order.xml?rev=354337&view=auto
==============================================================================
--- ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/sql/Order.xml (added)
+++ ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/sql/Order.xml Mon Dec  5 22:39:31 2005
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
+    "http://ibatis.apache.org/dtd/sql-map-2.dtd">
+
+<sqlMap namespace="Order">
+
+  <typeAlias alias="order" type="com.ibatis.jpetstore.domain.Order"/>
+
+  <statement id="getOrder" resultClass="order" parameterClass="int">
+    select
+      BILLADDR1 AS billAddress1,
+      BILLADDR2 AS billAddress2,
+      BILLCITY,
+      BILLCOUNTRY,
+      BILLSTATE,
+      BILLTOFIRSTNAME,
+      BILLTOLASTNAME,
+      BILLZIP,
+      SHIPADDR1 AS shipAddress1,
+      SHIPADDR2 AS shipAddress2,
+      SHIPCITY,
+      SHIPCOUNTRY,
+      SHIPSTATE,
+      SHIPTOFIRSTNAME,
+      SHIPTOLASTNAME,
+      SHIPZIP,
+      CARDTYPE,
+      COURIER,
+      CREDITCARD,
+      EXPRDATE AS expiryDate,
+      LOCALE,
+      ORDERDATE,
+      ORDERS.ORDERID,
+      TOTALPRICE,
+      USERID AS username,
+      STATUS
+    FROM ORDERS, ORDERSTATUS
+    WHERE ORDERS.ORDERID = #orderId#
+      AND ORDERS.ORDERID = ORDERSTATUS.ORDERID
+  </statement>
+
+  <select id="getOrdersByUsername" resultClass="order" parameterClass="string">
+    SELECT
+      BILLADDR1 AS billAddress1,
+      BILLADDR2 AS billAddress2,
+      BILLCITY,
+      BILLCOUNTRY,
+      BILLSTATE,
+      BILLTOFIRSTNAME,
+      BILLTOLASTNAME,
+      BILLZIP,
+      SHIPADDR1 AS shipAddress1,
+      SHIPADDR2 AS shipAddress2,
+      SHIPCITY,
+      SHIPCOUNTRY,
+      SHIPSTATE,
+      SHIPTOFIRSTNAME,
+      SHIPTOLASTNAME,
+      SHIPZIP,
+      CARDTYPE,
+      COURIER,
+      CREDITCARD,
+      EXPRDATE AS expiryDate,
+      LOCALE,
+      ORDERDATE,
+      ORDERS.ORDERID,
+      TOTALPRICE,
+      USERID AS username,
+      STATUS
+    FROM ORDERS, ORDERSTATUS
+    WHERE ORDERS.USERID = #value#
+      AND ORDERS.ORDERID = ORDERSTATUS.ORDERID
+    ORDER BY ORDERDATE
+  </select>
+
+  <insert id="insertOrder" parameterClass="order">
+    INSERT INTO ORDERS (ORDERID, USERID, ORDERDATE, SHIPADDR1, SHIPADDR2, SHIPCITY, SHIPSTATE,
+      SHIPZIP, SHIPCOUNTRY, BILLADDR1, BILLADDR2, BILLCITY, BILLSTATE, BILLZIP, BILLCOUNTRY,
+      COURIER, TOTALPRICE, BILLTOFIRSTNAME, BILLTOLASTNAME, SHIPTOFIRSTNAME, SHIPTOLASTNAME,
+      CREDITCARD, EXPRDATE, CARDTYPE, LOCALE)
+    VALUES(#orderId#, #username#, #orderDate#, #shipAddress1#, #shipAddress2:VARCHAR#, #shipCity#,
+      #shipState#, #shipZip#, #shipCountry#, #billAddress1#, #billAddress2:VARCHAR#, #billCity#,
+      #billState#, #billZip#, #billCountry#, #courier#, #totalPrice#, #billToFirstName#, #billToLastName#,
+      #shipToFirstName#, #shipToLastName#, #creditCard#, #expiryDate#, #cardType#, #locale#)
+  </insert>
+
+  <insert id="insertOrderStatus" parameterClass="order">
+    INSERT INTO ORDERSTATUS (ORDERID, LINENUM, TIMESTAMP, STATUS)
+    VALUES (#orderId:NUMERIC#, #orderId:NUMERIC#, #orderDate:TIMESTAMP#, #status:VARCHAR#)
+  </insert>
+
+</sqlMap>

Added: ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/sql/Product.xml
URL: http://svn.apache.org/viewcvs/ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/sql/Product.xml?rev=354337&view=auto
==============================================================================
--- ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/sql/Product.xml (added)
+++ ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/sql/Product.xml Mon Dec  5 22:39:31 2005
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
+    "http://ibatis.apache.org/dtd/sql-map-2.dtd">
+
+<sqlMap namespace="Product">
+
+  <typeAlias alias="product" type="com.ibatis.jpetstore.domain.Product"/>
+
+  <cacheModel id="productCache" type="LRU">
+    <flushInterval hours="24"/>
+    <property name="size" value="100"/>
+  </cacheModel>
+
+  <select id="getProduct" resultClass="product" parameterClass="string" cacheModel="productCache">
+    SELECT
+      PRODUCTID,
+      NAME,
+      DESCN as description,
+      CATEGORY as categoryId
+    FROM PRODUCT
+    WHERE PRODUCTID = #productId#
+  </select>
+
+  <select id="getProductListByCategory" resultClass="product" parameterClass="string" cacheModel="productCache">
+    SELECT
+      PRODUCTID,
+      NAME,
+      DESCN as description,
+      CATEGORY as categoryId
+    FROM PRODUCT
+    WHERE CATEGORY = #value#
+  </select>
+
+  <select id="searchProductList" resultClass="product" >
+    select
+      PRODUCTID,
+      NAME,
+      DESCN as description,
+      CATEGORY as categoryId
+    from PRODUCT
+    <dynamic prepend="WHERE">
+      <iterate property="keywordList" open="" close="" conjunction="OR">
+        lower(name) like #keywordList[]# OR lower(category) like #keywordList[]# OR lower(descn) like #keywordList[]#
+      </iterate>
+    </dynamic>
+  </select>
+
+</sqlMap>

Added: ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/sql/Sequence.xml
URL: http://svn.apache.org/viewcvs/ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/sql/Sequence.xml?rev=354337&view=auto
==============================================================================
--- ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/sql/Sequence.xml (added)
+++ ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/sql/Sequence.xml Mon Dec  5 22:39:31 2005
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
+    "http://ibatis.apache.org/dtd/sql-map-2.dtd">
+
+<sqlMap namespace="Sequence">
+
+  <typeAlias alias="sequence" type="com.ibatis.jpetstore.domain.Sequence"/>
+
+  <select id="getSequence" resultClass="sequence" parameterClass="sequence">
+    SELECT name, nextid
+    FROM SEQUENCE
+    WHERE NAME = #name#
+  </select>
+
+  <update id="updateSequence" parameterClass="sequence">
+    UPDATE SEQUENCE
+    SET NEXTID = #nextId#
+    WHERE NAME = #name#
+  </update>
+
+</sqlMap>

Added: ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/sql/sql-map-config.xml
URL: http://svn.apache.org/viewcvs/ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/sql/sql-map-config.xml?rev=354337&view=auto
==============================================================================
--- ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/sql/sql-map-config.xml (added)
+++ ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/sql/sql-map-config.xml Mon Dec  5 22:39:31 2005
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<!DOCTYPE sqlMapConfig PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
+    "http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
+
+<sqlMapConfig>
+
+  <properties resource="properties/database.properties"/>
+
+  <transactionManager type="JDBC">
+    <dataSource type="SIMPLE">
+      <property value="${driver}" name="JDBC.Driver"/>
+      <property value="${url}" name="JDBC.ConnectionURL"/>
+      <property value="${username}" name="JDBC.Username"/>
+      <property value="${password}" name="JDBC.Password"/>
+    </dataSource>
+  </transactionManager>
+
+  <sqlMap resource="com/ibatis/jpetstore/persistence/sqlmapdao/sql/Account.xml"/>
+  <sqlMap resource="com/ibatis/jpetstore/persistence/sqlmapdao/sql/Category.xml"/>
+  <sqlMap resource="com/ibatis/jpetstore/persistence/sqlmapdao/sql/Product.xml"/>
+  <sqlMap resource="com/ibatis/jpetstore/persistence/sqlmapdao/sql/Sequence.xml"/>
+  <sqlMap resource="com/ibatis/jpetstore/persistence/sqlmapdao/sql/LineItem.xml"/>
+  <sqlMap resource="com/ibatis/jpetstore/persistence/sqlmapdao/sql/Order.xml"/>
+  <sqlMap resource="com/ibatis/jpetstore/persistence/sqlmapdao/sql/Item.xml"/>
+
+</sqlMapConfig>

Added: ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/presentation/AbstractBean.java
URL: http://svn.apache.org/viewcvs/ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/presentation/AbstractBean.java?rev=354337&view=auto
==============================================================================
--- ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/presentation/AbstractBean.java (added)
+++ ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/presentation/AbstractBean.java Mon Dec  5 22:39:31 2005
@@ -0,0 +1,18 @@
+package com.ibatis.jpetstore.presentation;
+
+import org.apache.struts.beanaction.ActionContext;
+import org.apache.struts.beanaction.BaseBean;
+
+public abstract class AbstractBean extends BaseBean {
+
+  public static final String SUCCESS = "success";
+  public static final String FAILURE = "failure";
+  public static final String SIGNON = "signon";
+  public static final String SHIPPING = "shipping";
+  public static final String CONFIRM = "confirm";
+
+  protected void setMessage(String value) {
+    ActionContext.getActionContext().getRequestMap().put("message", value);
+  }
+  
+}

Added: ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/presentation/AccountBean.java
URL: http://svn.apache.org/viewcvs/ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/presentation/AccountBean.java?rev=354337&view=auto
==============================================================================
--- ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/presentation/AccountBean.java (added)
+++ ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/presentation/AccountBean.java Mon Dec  5 22:39:31 2005
@@ -0,0 +1,205 @@
+package com.ibatis.jpetstore.presentation;
+
+import com.ibatis.common.util.PaginatedList;
+import com.ibatis.jpetstore.domain.Account;
+import com.ibatis.jpetstore.service.AccountService;
+import com.ibatis.jpetstore.service.CatalogService;
+import org.apache.struts.beanaction.BeanActionException;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public class AccountBean extends AbstractBean {
+
+  private static final List LANGUAGE_LIST;
+  private static final List CATEGORY_LIST;
+
+  private AccountService accountService;
+  private CatalogService catalogService;
+
+  private Account account;
+  private String repeatedPassword;
+  private String pageDirection;
+  private String validation;
+  private PaginatedList myList;
+  private boolean authenticated;
+
+  static {
+    List langList = new ArrayList();
+    langList.add("english");
+    langList.add("japanese");
+    LANGUAGE_LIST = Collections.unmodifiableList(langList);
+
+    List catList = new ArrayList();
+    catList.add("FISH");
+    catList.add("DOGS");
+    catList.add("REPTILES");
+    catList.add("CATS");
+    catList.add("BIRDS");
+    CATEGORY_LIST = Collections.unmodifiableList(catList);
+  }
+
+  public AccountBean() {
+    this(new AccountService(), new CatalogService());
+  }
+
+  public AccountBean(AccountService accountService, CatalogService catalogService) {
+    account = new Account();
+    this.accountService = accountService;
+    this.catalogService = catalogService;
+  }
+
+  public String getUsername() {
+    return account.getUsername();
+  }
+
+  public void setUsername(String username) {
+    account.setUsername(username);
+  }
+
+  public String getPassword() {
+    return account.getPassword();
+  }
+
+  public void setPassword(String password) {
+    account.setPassword(password);
+  }
+
+  public PaginatedList getMyList() {
+    return myList;
+  }
+
+  public void setMyList(PaginatedList myList) {
+    this.myList = myList;
+  }
+
+  public String getRepeatedPassword() {
+    return repeatedPassword;
+  }
+
+  public void setRepeatedPassword(String repeatedPassword) {
+    this.repeatedPassword = repeatedPassword;
+  }
+
+  public Account getAccount() {
+    return account;
+  }
+
+  public void setAccount(Account account) {
+    this.account = account;
+  }
+
+
+  public List getLanguages() {
+    return LANGUAGE_LIST;
+  }
+
+  public List getCategories() {
+    return CATEGORY_LIST;
+  }
+
+  public String getPageDirection() {
+    return pageDirection;
+  }
+
+  public void setPageDirection(String pageDirection) {
+    this.pageDirection = pageDirection;
+  }
+
+  public String getValidation() {
+    return validation;
+  }
+
+  public void setValidation(String validation) {
+    this.validation = validation;
+  }
+
+  public String newAccount() {
+    try {
+      accountService.insertAccount(account);
+      account = accountService.getAccount(account.getUsername());
+      myList = catalogService.getProductListByCategory(account.getFavouriteCategoryId());
+      authenticated = true;
+      repeatedPassword = null;
+      return SUCCESS;
+    } catch (Exception e) {
+      throw new BeanActionException ("There was a problem creating your Account Information.  Cause: " + e, e);
+    }
+  }
+
+  public String editAccountForm() {
+    try {
+      account = accountService.getAccount(account.getUsername());
+      return SUCCESS;
+    } catch (Exception e) {
+      throw new BeanActionException ("There was a problem retrieving your Account Information. Cause: "+e, e);
+    }
+  }
+
+  public String editAccount() {
+    try {
+      accountService.updateAccount(account);
+      account = accountService.getAccount(account.getUsername());
+      myList = catalogService.getProductListByCategory(account.getFavouriteCategoryId());
+      return SUCCESS;
+    } catch (Exception e) {
+      throw new BeanActionException ("There was a problem updating your Account Information. Cause: "+e, e);
+    }
+  }
+
+  public String switchMyListPage () {
+    if ("next".equals(pageDirection)) {
+      myList.nextPage();
+    } else if ("previous".equals(pageDirection)) {
+      myList.previousPage();
+    }
+    return SUCCESS;
+  }
+
+  public String signon() {
+
+    account = accountService.getAccount(account.getUsername(), account.getPassword());
+
+    if (account == null || account == null) {
+      String value = "Invalid username or password.  Signon failed.";
+      setMessage(value);
+      clear();
+      return FAILURE;
+    } else {
+      account.setPassword(null);
+
+      myList = catalogService.getProductListByCategory(account.getFavouriteCategoryId());
+
+      authenticated = true;
+
+      return SUCCESS;
+    }
+  }
+
+  public String signoff() {
+    //ActionContext.getActionContext().getRequest().getSession().invalidate();
+    clear();
+    return SUCCESS;
+  }
+
+  public boolean isAuthenticated() {
+    return authenticated && account != null && account.getUsername() != null;
+  }
+
+  public void reset() {
+    if (account != null) {
+      account.setBannerOption(false);
+      account.setListOption(false);
+    }
+  }
+
+  public void clear() {
+    account = new Account();
+    repeatedPassword = null;
+    pageDirection = null;
+    myList = null;
+    authenticated = false;
+  }
+
+}

Added: ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/presentation/CartBean.java
URL: http://svn.apache.org/viewcvs/ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/presentation/CartBean.java?rev=354337&view=auto
==============================================================================
--- ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/presentation/CartBean.java (added)
+++ ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/presentation/CartBean.java Mon Dec  5 22:39:31 2005
@@ -0,0 +1,119 @@
+package com.ibatis.jpetstore.presentation;
+
+import com.ibatis.jpetstore.domain.Cart;
+import com.ibatis.jpetstore.domain.CartItem;
+import com.ibatis.jpetstore.domain.Item;
+import com.ibatis.jpetstore.service.CatalogService;
+import org.apache.struts.beanaction.ActionContext;
+
+import java.util.Iterator;
+import java.util.Map;
+
+public class CartBean extends AbstractBean {
+
+  private CatalogService catalogService;
+
+  private Cart cart = new Cart();
+  private String workingItemId;
+  private String pageDirection;
+
+  public CartBean() {
+    this (new CatalogService());
+  }
+
+  public CartBean(CatalogService catalogService) {
+    this.catalogService= catalogService;
+  }
+
+  public Cart getCart() {
+    return cart;
+  }
+
+  public void setCart(Cart cart) {
+    this.cart = cart;
+  }
+
+  public String getWorkingItemId() {
+    return workingItemId;
+  }
+
+  public void setWorkingItemId(String workingItemId) {
+    this.workingItemId = workingItemId;
+  }
+
+  public String getPageDirection() {
+    return pageDirection;
+  }
+
+  public void setPageDirection(String pageDirection) {
+    this.pageDirection = pageDirection;
+  }
+
+  public String addItemToCart() {
+    if (cart.containsItemId(workingItemId)) {
+      cart.incrementQuantityByItemId(workingItemId);
+    } else {
+      // isInStock is a "real-time" property that must be updated
+      // every time an item is added to the cart, even if other
+      // item details are cached.
+      boolean isInStock = catalogService.isItemInStock(workingItemId);
+      Item item = catalogService.getItem(workingItemId);
+      cart.addItem(item, isInStock);
+    }
+
+    return SUCCESS;
+  }
+
+  public String removeItemFromCart() {
+
+    Item item = cart.removeItemById(workingItemId);
+
+    if (item == null) {
+      setMessage("Attempted to remove null CartItem from Cart.");
+      return FAILURE;
+    } else {
+      return SUCCESS;
+    }
+  }
+
+  public String updateCartQuantities() {
+    Map parameterMap = ActionContext.getActionContext().getParameterMap();
+
+    Iterator cartItems = getCart().getAllCartItems();
+    while (cartItems.hasNext()) {
+      CartItem cartItem = (CartItem) cartItems.next();
+      String itemId = cartItem.getItem().getItemId();
+      try {
+        int quantity = Integer.parseInt((String) parameterMap.get(itemId));
+        getCart().setQuantityByItemId(itemId, quantity);
+        if (quantity < 1) {
+          cartItems.remove();
+        }
+      } catch (Exception e) {
+        //ignore parse exceptions on purpose
+      }
+    }
+
+    return SUCCESS;
+  }
+
+  public String switchCartPage() {
+    if ("next".equals(pageDirection)) {
+      cart.getCartItemList().nextPage();
+    } else if ("previous".equals(pageDirection)) {
+      cart.getCartItemList().previousPage();
+    }
+    return SUCCESS;
+  }
+
+  public String viewCart() {
+    return SUCCESS;
+  }
+
+  public void clear() {
+    cart = new Cart();
+    workingItemId = null;
+    pageDirection = null;
+  }
+
+}

Added: ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/presentation/CatalogBean.java
URL: http://svn.apache.org/viewcvs/ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/presentation/CatalogBean.java?rev=354337&view=auto
==============================================================================
--- ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/presentation/CatalogBean.java (added)
+++ ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/presentation/CatalogBean.java Mon Dec  5 22:39:31 2005
@@ -0,0 +1,191 @@
+package com.ibatis.jpetstore.presentation;
+
+import com.ibatis.common.util.PaginatedList;
+import com.ibatis.jpetstore.domain.Category;
+import com.ibatis.jpetstore.domain.Item;
+import com.ibatis.jpetstore.domain.Product;
+import com.ibatis.jpetstore.service.CatalogService;
+
+public class CatalogBean extends AbstractBean {
+
+  private CatalogService catalogService;
+
+  private String keyword;
+  private String pageDirection;
+
+  private String categoryId;
+  private Category category;
+  private PaginatedList categoryList;
+
+  private String productId;
+  private Product product;
+  private PaginatedList productList;
+
+  private String itemId;
+  private Item item;
+  private PaginatedList itemList;
+
+  public CatalogBean() {
+    this(new CatalogService());
+  }
+
+  public CatalogBean(CatalogService catalogService) {
+    this.catalogService = catalogService;
+  }
+
+  public String getKeyword() {
+    return keyword;
+  }
+
+  public void setKeyword(String keyword) {
+    this.keyword = keyword;
+  }
+
+  public String getPageDirection() {
+    return pageDirection;
+  }
+
+  public void setPageDirection(String pageDirection) {
+    this.pageDirection = pageDirection;
+  }
+
+  public String getCategoryId() {
+    return categoryId;
+  }
+
+  public void setCategoryId(String categoryId) {
+    this.categoryId = categoryId;
+  }
+
+  public String getProductId() {
+    return productId;
+  }
+
+  public void setProductId(String productId) {
+    this.productId = productId;
+  }
+
+  public String getItemId() {
+    return itemId;
+  }
+
+  public void setItemId(String itemId) {
+    this.itemId = itemId;
+  }
+
+  public Category getCategory() {
+    return category;
+  }
+
+  public void setCategory(Category category) {
+    this.category = category;
+  }
+
+  public Product getProduct() {
+    return product;
+  }
+
+  public void setProduct(Product product) {
+    this.product = product;
+  }
+
+  public Item getItem() {
+    return item;
+  }
+
+  public void setItem(Item item) {
+    this.item = item;
+  }
+
+  public PaginatedList getCategoryList() {
+    return categoryList;
+  }
+
+  public void setCategoryList(PaginatedList categoryList) {
+    this.categoryList = categoryList;
+  }
+
+  public PaginatedList getProductList() {
+    return productList;
+  }
+
+  public void setProductList(PaginatedList productList) {
+    this.productList = productList;
+  }
+
+  public PaginatedList getItemList() {
+    return itemList;
+  }
+
+  public void setItemList(PaginatedList itemList) {
+    this.itemList = itemList;
+  }
+
+  public String viewCategory() {
+    if (categoryId != null) {
+      productList = catalogService.getProductListByCategory(categoryId);
+      category = catalogService.getCategory(categoryId);
+    }
+    return SUCCESS;
+  }
+
+  public String viewProduct() {
+    if (productId != null) {
+      itemList = catalogService.getItemListByProduct(productId);
+      product = catalogService.getProduct(productId);
+    }
+    return SUCCESS;
+  }
+
+  public String viewItem() {
+    item = catalogService.getItem(itemId);
+    product = item.getProduct();
+    return SUCCESS;
+  }
+
+  public String searchProducts() {
+    if (keyword == null || keyword.length() < 1) {
+      setMessage("Please enter a keyword to search for, then press the search button.");
+      return FAILURE;
+    } else {
+      productList = catalogService.searchProductList(keyword.toLowerCase());
+      return SUCCESS;
+    }
+  }
+
+  public String switchProductListPage() {
+    if ("next".equals(pageDirection)) {
+      productList.nextPage();
+    } else if ("previous".equals(pageDirection)) {
+      productList.previousPage();
+    }
+    return SUCCESS;
+  }
+
+  public String switchItemListPage() {
+    if ("next".equals(pageDirection)) {
+      itemList.nextPage();
+    } else if ("previous".equals(pageDirection)) {
+      itemList.previousPage();
+    }
+    return SUCCESS;
+  }
+
+  public void clear () {
+    keyword = null;
+    pageDirection = null;
+
+    categoryId = null;
+    category = null;
+    categoryList = null;
+
+    productId = null;
+    product = null;
+    productList = null;
+
+    itemId = null;
+    item = null;
+    itemList = null;
+  }
+
+}

Added: ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/presentation/OrderBean.java
URL: http://svn.apache.org/viewcvs/ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/presentation/OrderBean.java?rev=354337&view=auto
==============================================================================
--- ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/presentation/OrderBean.java (added)
+++ ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/presentation/OrderBean.java Mon Dec  5 22:39:31 2005
@@ -0,0 +1,182 @@
+package com.ibatis.jpetstore.presentation;
+
+import com.ibatis.common.util.PaginatedList;
+import com.ibatis.jpetstore.domain.Order;
+import com.ibatis.jpetstore.service.AccountService;
+import com.ibatis.jpetstore.service.OrderService;
+import org.apache.struts.beanaction.ActionContext;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+public class OrderBean extends AbstractBean {
+
+  private static final List CARD_TYPE_LIST;
+
+  private AccountService accountService;
+  private OrderService orderService;
+
+  private Order order;
+  private int orderId;
+  private boolean shippingAddressRequired;
+  private boolean confirmed;
+  private PaginatedList orderList;
+  private String pageDirection;
+
+  static {
+    List cardList = new ArrayList();
+    cardList.add("Visa");
+    cardList.add("MasterCard");
+    cardList.add("American Express");
+    CARD_TYPE_LIST = Collections.unmodifiableList(cardList);
+  }
+
+  public OrderBean() {
+    this(new AccountService(), new OrderService());
+  }
+
+  public OrderBean(AccountService accountService, OrderService orderService) {
+    order = new Order();
+    shippingAddressRequired = false;
+    confirmed = false;
+    this.accountService = accountService;
+    this.orderService = orderService;
+  }
+
+  public int getOrderId() {
+    return orderId;
+  }
+
+  public void setOrderId(int orderId) {
+    this.orderId = orderId;
+  }
+
+  public Order getOrder() {
+    return order;
+  }
+
+  public void setOrder(Order order) {
+    this.order = order;
+  }
+
+  public boolean isShippingAddressRequired() {
+    return shippingAddressRequired;
+  }
+
+  public void setShippingAddressRequired(boolean shippingAddressRequired) {
+    this.shippingAddressRequired = shippingAddressRequired;
+  }
+
+  public boolean isConfirmed() {
+    return confirmed;
+  }
+
+  public void setConfirmed(boolean confirmed) {
+    this.confirmed = confirmed;
+  }
+
+  public List getCreditCardTypes() {
+    return CARD_TYPE_LIST;
+  }
+
+  public String getPageDirection() {
+    return pageDirection;
+  }
+
+  public void setPageDirection(String pageDirection) {
+    this.pageDirection = pageDirection;
+  }
+
+  public PaginatedList getOrderList() {
+    return orderList;
+  }
+
+  public String listOrders() {
+    Map sessionMap = ActionContext.getActionContext().getSessionMap();
+    AccountBean accountBean = (AccountBean) sessionMap.get("accountBean");
+    orderList = orderService.getOrdersByUsername(accountBean.getAccount().getUsername());
+    return SUCCESS;
+  }
+
+  public String switchOrderPage() {
+    if ("next".equals(pageDirection)) {
+      orderList.nextPage();
+    } else if ("previous".equals(pageDirection)) {
+      orderList.previousPage();
+    }
+    return SUCCESS;
+  }
+
+  public String newOrderForm() {
+    Map sessionMap = ActionContext.getActionContext().getSessionMap();
+    AccountBean accountBean = (AccountBean) sessionMap.get("accountBean");
+    CartBean cartBean = (CartBean) sessionMap.get("cartBean");
+
+    clear();
+    if (accountBean == null || !accountBean.isAuthenticated()){
+      setMessage("You must sign on before attempting to check out.  Please sign on and try checking out again.");
+      return SIGNON;
+    } else if (cartBean != null) {
+      order.initOrder(accountBean.getAccount(), cartBean.getCart());
+      return SUCCESS;
+    } else {
+      setMessage("An order could not be created because a cart could not be found.");
+      return FAILURE;
+    }
+  }
+
+  public String newOrder() {
+    Map sessionMap = ActionContext.getActionContext().getSessionMap();
+
+    if (shippingAddressRequired) {
+      shippingAddressRequired = false;
+      return SHIPPING;
+    } else if (!isConfirmed()) {
+      return CONFIRM;
+    } else if (getOrder() != null) {
+
+      orderService.insertOrder(order);
+
+      CartBean cartBean = (CartBean)sessionMap.get("cartBean");
+      cartBean.clear();
+
+      setMessage("Thank you, your order has been submitted.");
+
+      return SUCCESS;
+    } else {
+      setMessage("An error occurred processing your order (order was null).");
+      return FAILURE;
+    }
+  }
+
+  public String viewOrder() {
+    Map sessionMap = ActionContext.getActionContext().getSessionMap();
+    AccountBean accountBean = (AccountBean) sessionMap.get("accountBean");
+
+    order = orderService.getOrder(orderId);
+
+    if (accountBean.getAccount().getUsername().equals(order.getUsername())) {
+      return SUCCESS;
+    } else {
+      order = null;
+      setMessage("You may only view your own orders.");
+      return FAILURE;
+    }
+  }
+
+  public void reset() {
+    shippingAddressRequired = false;
+  }
+
+  public void clear() {
+    order = new Order();
+    orderId = 0;
+    shippingAddressRequired = false;
+    confirmed = false;
+    orderList = null;
+    pageDirection = null;
+  }
+
+}

Added: ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/service/AccountService.java
URL: http://svn.apache.org/viewcvs/ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/service/AccountService.java?rev=354337&view=auto
==============================================================================
--- ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/service/AccountService.java (added)
+++ ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/service/AccountService.java Mon Dec  5 22:39:31 2005
@@ -0,0 +1,37 @@
+package com.ibatis.jpetstore.service;
+
+import com.ibatis.dao.client.DaoManager;
+import com.ibatis.jpetstore.domain.Account;
+import com.ibatis.jpetstore.persistence.iface.AccountDao;
+import com.ibatis.jpetstore.persistence.DaoConfig;
+
+public class AccountService {
+
+  private AccountDao accountDao;
+
+  public AccountService() {
+    DaoManager daoMgr = DaoConfig.getDaoManager();
+    this.accountDao = (AccountDao) daoMgr.getDao(AccountDao.class);
+  }
+
+  public AccountService(AccountDao accountDao) {
+    this.accountDao = accountDao;
+  }
+
+  public Account getAccount(String username) {
+    return accountDao.getAccount(username);
+  }
+
+  public Account getAccount(String username, String password) {
+    return accountDao.getAccount(username, password);
+  }
+
+  public void insertAccount(Account account) {
+    accountDao.insertAccount(account);
+  }
+
+  public void updateAccount(Account account) {
+    accountDao.updateAccount(account);
+  }
+
+}

Added: ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/service/CatalogService.java
URL: http://svn.apache.org/viewcvs/ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/service/CatalogService.java?rev=354337&view=auto
==============================================================================
--- ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/service/CatalogService.java (added)
+++ ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/service/CatalogService.java Mon Dec  5 22:39:31 2005
@@ -0,0 +1,66 @@
+package com.ibatis.jpetstore.service;
+
+import com.ibatis.common.util.PaginatedList;
+import com.ibatis.dao.client.DaoManager;
+import com.ibatis.jpetstore.domain.Category;
+import com.ibatis.jpetstore.domain.Item;
+import com.ibatis.jpetstore.domain.Product;
+import com.ibatis.jpetstore.persistence.iface.CategoryDao;
+import com.ibatis.jpetstore.persistence.iface.ItemDao;
+import com.ibatis.jpetstore.persistence.iface.ProductDao;
+import com.ibatis.jpetstore.persistence.DaoConfig;
+
+import java.util.List;
+
+public class CatalogService {
+
+  private CategoryDao categoryDao;
+  private ItemDao itemDao;
+  private ProductDao productDao;
+
+  public CatalogService() {
+    DaoManager daoManager = DaoConfig.getDaoManager();
+    categoryDao = (CategoryDao) daoManager.getDao(CategoryDao.class);
+    productDao = (ProductDao) daoManager.getDao(ProductDao.class);
+    itemDao = (ItemDao) daoManager.getDao(ItemDao.class);
+  }
+
+  public CatalogService(CategoryDao categoryDao, ItemDao itemDao, ProductDao productDao) {
+    this.categoryDao = categoryDao;
+    this.itemDao = itemDao;
+    this.productDao = productDao;
+  }
+
+  public List getCategoryList() {
+    return categoryDao.getCategoryList();
+  }
+
+  public Category getCategory(String categoryId) {
+    return categoryDao.getCategory(categoryId);
+  }
+
+  public Product getProduct(String productId) {
+    return productDao.getProduct(productId);
+  }
+
+  public PaginatedList getProductListByCategory(String categoryId) {
+    return productDao.getProductListByCategory(categoryId);
+  }
+
+  public PaginatedList searchProductList(String keywords) {
+    return productDao.searchProductList(keywords);
+  }
+
+  public PaginatedList getItemListByProduct(String productId) {
+    return itemDao.getItemListByProduct(productId);
+  }
+
+  public Item getItem(String itemId) {
+    return itemDao.getItem(itemId);
+  }
+
+  public boolean isItemInStock(String itemId) {
+    return itemDao.isItemInStock(itemId);
+  }
+
+}
\ No newline at end of file

Added: ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/service/OrderService.java
URL: http://svn.apache.org/viewcvs/ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/service/OrderService.java?rev=354337&view=auto
==============================================================================
--- ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/service/OrderService.java (added)
+++ ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/service/OrderService.java Mon Dec  5 22:39:31 2005
@@ -0,0 +1,80 @@
+package com.ibatis.jpetstore.service;
+
+import com.ibatis.common.util.PaginatedList;
+import com.ibatis.dao.client.DaoManager;
+import com.ibatis.jpetstore.domain.LineItem;
+import com.ibatis.jpetstore.domain.Order;
+import com.ibatis.jpetstore.persistence.DaoConfig;
+import com.ibatis.jpetstore.persistence.iface.ItemDao;
+import com.ibatis.jpetstore.persistence.iface.OrderDao;
+import com.ibatis.jpetstore.persistence.iface.SequenceDao;
+
+public class OrderService {
+
+  private DaoManager daoManager;
+
+  private ItemDao itemDao;
+  private OrderDao orderDao;
+  private SequenceDao sequenceDao;
+
+  public OrderService() {
+    daoManager = DaoConfig.getDaoManager();
+    itemDao = (ItemDao) daoManager.getDao(ItemDao.class);
+    sequenceDao = (SequenceDao) daoManager.getDao(SequenceDao.class);
+    orderDao = (OrderDao) daoManager.getDao(OrderDao.class);
+  }
+
+  public OrderService(DaoManager daoManager, ItemDao itemDao, OrderDao orderDao, SequenceDao sequenceDao) {
+    this.daoManager = daoManager;
+    this.itemDao = itemDao;
+    this.orderDao = orderDao;
+    this.sequenceDao = sequenceDao;
+  }
+
+  public void insertOrder(Order order) {
+    try {
+      // Get the next id within a separate transaction
+      order.setOrderId(getNextId("ordernum"));
+
+      daoManager.startTransaction();
+
+      itemDao.updateAllQuantitiesFromOrder(order);
+      orderDao.insertOrder(order);
+
+      daoManager.commitTransaction();
+    } finally {
+      daoManager.endTransaction();
+    }
+  }
+
+  public Order getOrder(int orderId) {
+    Order order = null;
+
+    try {
+      daoManager.startTransaction();
+
+      order = orderDao.getOrder(orderId);
+
+      for (int i = 0; i < order.getLineItems().size(); i++) {
+        LineItem lineItem = (LineItem) order.getLineItems().get(i);
+        lineItem.setItem(itemDao.getItem(lineItem.getItemId()));
+      }
+
+      daoManager.commitTransaction();
+    } finally {
+      daoManager.endTransaction();
+    }
+
+    return order;
+  }
+
+  public PaginatedList getOrdersByUsername(String username) {
+    return orderDao.getOrdersByUsername(username);
+  }
+
+  public int getNextId(String key) {
+    return sequenceDao.getNextId(key);
+  }
+
+
+}

Added: ibatis/trunk/java/jpetstore/jpetstore5/src/ddl/hsql/jpetstore-hsqldb-dataload.sql
URL: http://svn.apache.org/viewcvs/ibatis/trunk/java/jpetstore/jpetstore5/src/ddl/hsql/jpetstore-hsqldb-dataload.sql?rev=354337&view=auto
==============================================================================
--- ibatis/trunk/java/jpetstore/jpetstore5/src/ddl/hsql/jpetstore-hsqldb-dataload.sql (added)
+++ ibatis/trunk/java/jpetstore/jpetstore5/src/ddl/hsql/jpetstore-hsqldb-dataload.sql Mon Dec  5 22:39:31 2005
@@ -0,0 +1,101 @@
+INSERT INTO sequence VALUES('ordernum', 1000);
+
+INSERT INTO signon VALUES('j2ee','j2ee');
+INSERT INTO signon VALUES('ACID','ACID');
+
+INSERT INTO account VALUES('j2ee','yourname@yourdomain.com','ABC', 'XYX', 'OK', '901 San Antonio Road', 'MS UCUP02-206', 'Palo Alto', 'CA', '94303', 'USA',  '555-555-5555');
+INSERT INTO account VALUES('ACID','acid@yourdomain.com','ABC', 'XYX', 'OK', '901 San Antonio Road', 'MS UCUP02-206', 'Palo Alto', 'CA', '94303', 'USA',  '555-555-5555');
+
+INSERT INTO profile VALUES('j2ee','english','DOGS',1,1);
+INSERT INTO profile VALUES('ACID','english','CATS',1,1);
+
+INSERT INTO bannerdata VALUES ('FISH','<image src="../images/banner_fish.gif">');
+INSERT INTO bannerdata VALUES ('CATS','<image src="../images/banner_cats.gif">');
+INSERT INTO bannerdata VALUES ('DOGS','<image src="../images/banner_dogs.gif">');
+INSERT INTO bannerdata VALUES ('REPTILES','<image src="../images/banner_reptiles.gif">');
+INSERT INTO bannerdata VALUES ('BIRDS','<image src="../images/banner_birds.gif">');
+
+INSERT INTO category VALUES ('FISH','Fish','<image src="../images/fish_icon.gif"><font size="5" color="blue"> Fish</font>');
+INSERT INTO category VALUES ('DOGS','Dogs','<image src="../images/dogs_icon.gif"><font size="5" color="blue"> Dogs</font>');
+INSERT INTO category VALUES ('REPTILES','Reptiles','<image src="../images/reptiles_icon.gif"><font size="5" color="blue"> Reptiles</font>');
+INSERT INTO category VALUES ('CATS','Cats','<image src="../images/cats_icon.gif"><font size="5" color="blue"> Cats</font>');
+INSERT INTO category VALUES ('BIRDS','Birds','<image src="../images/birds_icon.gif"><font size="5" color="blue"> Birds</font>');
+
+INSERT INTO product VALUES ('FI-SW-01','FISH','Angelfish','<image src="../images/fish1.gif">Salt Water fish from Australia');
+INSERT INTO product VALUES ('FI-SW-02','FISH','Tiger Shark','<image src="../images/fish4.gif">Salt Water fish from Australia');
+INSERT INTO product VALUES ('FI-FW-01','FISH', 'Koi','<image src="../images/fish3.gif">Fresh Water fish from Japan');
+INSERT INTO product VALUES ('FI-FW-02','FISH', 'Goldfish','<image src="../images/fish2.gif">Fresh Water fish from China');
+INSERT INTO product VALUES ('K9-BD-01','DOGS','Bulldog','<image src="../images/dog2.gif">Friendly dog from England');
+INSERT INTO product VALUES ('K9-PO-02','DOGS','Poodle','<image src="../images/dog6.gif">Cute dog from France');
+INSERT INTO product VALUES ('K9-DL-01','DOGS', 'Dalmation','<image src="../images/dog5.gif">Great dog for a Fire Station');
+INSERT INTO product VALUES ('K9-RT-01','DOGS', 'Golden Retriever','<image src="../images/dog1.gif">Great family dog');
+INSERT INTO product VALUES ('K9-RT-02','DOGS', 'Labrador Retriever','<image src="../images/dog5.gif">Great hunting dog');
+INSERT INTO product VALUES ('K9-CW-01','DOGS', 'Chihuahua','<image src="../images/dog4.gif">Great companion dog');
+INSERT INTO product VALUES ('RP-SN-01','REPTILES','Rattlesnake','<image src="../images/snake1.gif">Doubles as a watch dog');
+INSERT INTO product VALUES ('RP-LI-02','REPTILES','Iguana','<image src="../images/lizard1.gif">Friendly green friend');
+INSERT INTO product VALUES ('FL-DSH-01','CATS','Manx','<image src="../images/cat2.gif">Great for reducing mouse populations');
+INSERT INTO product VALUES ('FL-DLH-02','CATS','Persian','<image src="../images/cat1.gif">Friendly house cat, doubles as a princess');
+INSERT INTO product VALUES ('AV-CB-01','BIRDS','Amazon Parrot','<image src="../images/bird2.gif">Great companion for up to 75 years');
+INSERT INTO product VALUES ('AV-SB-02','BIRDS','Finch','<image src="../images/bird1.gif">Great stress reliever');
+
+INSERT INTO supplier VALUES (1,'XYZ Pets','AC','600 Avon Way','','Los Angeles','CA','94024','212-947-0797');
+INSERT INTO supplier VALUES (2,'ABC Pets','AC','700 Abalone Way','','San Francisco ','CA','94024','415-947-0797');
+
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-1','FI-SW-01',16.50,10.00,1,'P','Large');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-2','FI-SW-01',16.50,10.00,1,'P','Small');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-3','FI-SW-02',18.50,12.00,1,'P','Toothless');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-4','FI-FW-01',18.50,12.00,1,'P','Spotted');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-5','FI-FW-01',18.50,12.00,1,'P','Spotless');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-6','K9-BD-01',18.50,12.00,1,'P','Male Adult');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-7','K9-BD-01',18.50,12.00,1,'P','Female Puppy');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-8','K9-PO-02',18.50,12.00,1,'P','Male Puppy');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-9','K9-DL-01',18.50,12.00,1,'P','Spotless Male Puppy');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-10','K9-DL-01',18.50,12.00,1,'P','Spotted Adult Female');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-11','RP-SN-01',18.50,12.00,1,'P','Venomless');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-12','RP-SN-01',18.50,12.00,1,'P','Rattleless');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-13','RP-LI-02',18.50,12.00,1,'P','Green Adult');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-14','FL-DSH-01',58.50,12.00,1,'P','Tailless');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-15','FL-DSH-01',23.50,12.00,1,'P','With tail');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-16','FL-DLH-02',93.50,12.00,1,'P','Adult Female');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-17','FL-DLH-02',93.50,12.00,1,'P','Adult Male');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-18','AV-CB-01',193.50,92.00,1,'P','Adult Male');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-19','AV-SB-02',15.50, 2.00,1,'P','Adult Male');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-20','FI-FW-02',5.50, 2.00,1,'P','Adult Male');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-21','FI-FW-02',5.29, 1.00,1,'P','Adult Female');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-22','K9-RT-02',135.50, 100.00,1,'P','Adult Male');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-23','K9-RT-02',145.49, 100.00,1,'P','Adult Female');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-24','K9-RT-02',255.50, 92.00,1,'P','Adult Male');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-25','K9-RT-02',325.29, 90.00,1,'P','Adult Female');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-26','K9-CW-01',125.50, 92.00,1,'P','Adult Male');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-27','K9-CW-01',155.29, 90.00,1,'P','Adult Female');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-28','K9-RT-01',155.29, 90.00,1,'P','Adult Female');
+
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-1',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-2',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-3',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-4',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-5',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-6',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-7',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-8',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-9',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-10',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-11',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-12',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-13',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-14',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-15',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-16',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-17',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-18',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-19',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-20',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-21',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-22',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-23',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-24',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-25',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-26',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-27',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-28',10000);
+

Added: ibatis/trunk/java/jpetstore/jpetstore5/src/ddl/hsql/jpetstore-hsqldb-schema.sql
URL: http://svn.apache.org/viewcvs/ibatis/trunk/java/jpetstore/jpetstore5/src/ddl/hsql/jpetstore-hsqldb-schema.sql?rev=354337&view=auto
==============================================================================
--- ibatis/trunk/java/jpetstore/jpetstore5/src/ddl/hsql/jpetstore-hsqldb-schema.sql (added)
+++ ibatis/trunk/java/jpetstore/jpetstore5/src/ddl/hsql/jpetstore-hsqldb-schema.sql Mon Dec  5 22:39:31 2005
@@ -0,0 +1,167 @@
+drop index productCat;
+drop index productName;
+drop index itemProd;
+
+drop table lineitem;
+drop table orderstatus;
+drop table orders;
+drop table bannerdata;
+drop table profile;
+drop table signon;
+drop table inventory;
+drop table item;
+drop table product;
+drop table account;
+drop table category;
+drop table supplier;
+drop table sequence;
+
+create table supplier (
+    suppid int not null,
+    name varchar(80) null,
+    status varchar(2) not null,
+    addr1 varchar(80) null,
+    addr2 varchar(80) null,
+    city varchar(80) null,
+    state varchar(80) null,
+    zip varchar(5) null,
+    phone varchar(80) null,
+    constraint pk_supplier primary key (suppid)
+);
+
+create table signon (
+    username varchar(25) not null,
+    password varchar(25)  not null,
+    constraint pk_signon primary key (username)
+);
+
+create table account (
+    userid varchar(80) not null,
+    email varchar(80) not null,
+    firstname varchar(80) not null,
+    lastname varchar(80) not null,
+    status varchar(2)  null,
+    addr1 varchar(80) not null,
+    addr2 varchar(40) null,
+    city varchar(80) not  null,
+    state varchar(80) not null,
+    zip varchar(20) not null,
+    country varchar(20) not null,
+    phone varchar(80) not null,
+    constraint pk_account primary key (userid)
+);
+
+create table profile (
+    userid varchar(80) not null,
+    langpref varchar(80) not null,
+    favcategory varchar(30),
+    mylistopt int,
+    banneropt int,
+    constraint pk_profile primary key (userid)
+);
+
+create table bannerdata (
+    favcategory varchar(80) not null,
+    bannername varchar(255)  null,
+    constraint pk_bannerdata primary key (favcategory)
+);
+
+create table orders (
+      orderid int not null,
+      userid varchar(80) not null,
+      orderdate date not null,
+      shipaddr1 varchar(80) not null,
+      shipaddr2 varchar(80) null,
+      shipcity varchar(80) not null,
+      shipstate varchar(80) not null,
+      shipzip varchar(20) not null,
+      shipcountry varchar(20) not null,
+      billaddr1 varchar(80) not null,
+      billaddr2 varchar(80)  null,
+      billcity varchar(80) not null,
+      billstate varchar(80) not null,
+      billzip varchar(20) not null,
+      billcountry varchar(20) not null,
+      courier varchar(80) not null,
+      totalprice decimal(10,2) not null,
+      billtofirstname varchar(80) not null,
+      billtolastname varchar(80) not null,
+      shiptofirstname varchar(80) not null,
+      shiptolastname varchar(80) not null,
+      creditcard varchar(80) not null,
+      exprdate varchar(7) not null,
+      cardtype varchar(80) not null,
+      locale varchar(80) not null,
+      constraint pk_orders primary key (orderid)
+);
+
+create table orderstatus (
+      orderid int not null,
+      linenum int not null,
+      timestamp date not null,
+      status varchar(2) not null,
+      constraint pk_orderstatus primary key (orderid, linenum)
+);
+
+create table lineitem (
+      orderid int not null,
+      linenum int not null,
+      itemid varchar(10) not null,
+      quantity int not null,
+      unitprice decimal(10,2) not null,
+      constraint pk_lineitem primary key (orderid, linenum)
+);
+
+create table category (
+	catid varchar(10) not null,
+	name varchar(80) null,
+	descn varchar(255) null,
+	constraint pk_category primary key (catid)
+);
+
+create table product (
+    productid varchar(10) not null,
+    category varchar(10) not null,
+    name varchar(80) null,
+    descn varchar(255) null,
+    constraint pk_product primary key (productid),
+        constraint fk_product_1 foreign key (category)
+        references category (catid)
+);
+
+create index productCat on product (category);
+create index productName on product (name);
+
+create table item (
+    itemid varchar(10) not null,
+    productid varchar(10) not null,
+    listprice decimal(10,2) null,
+    unitcost decimal(10,2) null,
+    supplier int null,
+    status varchar(2) null,
+    attr1 varchar(80) null,
+    attr2 varchar(80) null,
+    attr3 varchar(80) null,
+    attr4 varchar(80) null,
+    attr5 varchar(80) null,
+    constraint pk_item primary key (itemid),
+        constraint fk_item_1 foreign key (productid)
+        references product (productid),
+        constraint fk_item_2 foreign key (supplier)
+        references supplier (suppid)
+);
+
+create index itemProd on item (productid);
+
+create table inventory (
+    itemid varchar(10) not null,
+    qty int not null,
+    constraint pk_inventory primary key (itemid)
+);
+
+CREATE TABLE sequence
+(
+    name               varchar(30)  not null,
+    nextid             int          not null,
+    constraint pk_sequence primary key (name)
+);

Added: ibatis/trunk/java/jpetstore/jpetstore5/src/ddl/mssql/jpetstore-mssql-dataload.sql
URL: http://svn.apache.org/viewcvs/ibatis/trunk/java/jpetstore/jpetstore5/src/ddl/mssql/jpetstore-mssql-dataload.sql?rev=354337&view=auto
==============================================================================
--- ibatis/trunk/java/jpetstore/jpetstore5/src/ddl/mssql/jpetstore-mssql-dataload.sql (added)
+++ ibatis/trunk/java/jpetstore/jpetstore5/src/ddl/mssql/jpetstore-mssql-dataload.sql Mon Dec  5 22:39:31 2005
@@ -0,0 +1,102 @@
+INSERT INTO sequence VALUES('ordernum', 1000);
+INSERT INTO sequence VALUES('linenum', 1000);
+
+INSERT INTO signon VALUES('j2ee','j2ee');
+INSERT INTO signon VALUES('ACID','ACID');
+
+INSERT INTO account VALUES('j2ee','yourname@yourdomain.com','ABC', 'XYX', 'OK', '901 San Antonio Road', 'MS UCUP02-206', 'Palo Alto', 'CA', '94303', 'USA',  '555-555-5555');
+INSERT INTO account VALUES('ACID','acid@yourdomain.com','ABC', 'XYX', 'OK', '901 San Antonio Road', 'MS UCUP02-206', 'Palo Alto', 'CA', '94303', 'USA',  '555-555-5555');
+
+INSERT INTO profile VALUES('j2ee','english','DOGS','1','1');
+INSERT INTO profile VALUES('ACID','english','CATS','1','1');
+
+INSERT INTO bannerdata VALUES ('FISH','<image src="../images/banner_fish.gif">');
+INSERT INTO bannerdata VALUES ('CATS','<image src="../images/banner_cats.gif">');
+INSERT INTO bannerdata VALUES ('DOGS','<image src="../images/banner_dogs.gif">');
+INSERT INTO bannerdata VALUES ('REPTILES','<image src="../images/banner_reptiles.gif">');
+INSERT INTO bannerdata VALUES ('BIRDS','<image src="../images/banner_birds.gif">');
+
+INSERT INTO category VALUES ('FISH','Fish','<image src="../images/fish_icon.gif"><font size="5" color="blue"> Fish</font>');
+INSERT INTO category VALUES ('DOGS','Dogs','<image src="../images/dogs_icon.gif"><font size="5" color="blue"> Dogs</font>');
+INSERT INTO category VALUES ('REPTILES','Reptiles','<image src="../images/reptiles_icon.gif"><font size="5" color="blue"> Reptiles</font>');
+INSERT INTO category VALUES ('CATS','Cats','<image src="../images/cats_icon.gif"><font size="5" color="blue"> Cats</font>');
+INSERT INTO category VALUES ('BIRDS','Birds','<image src="../images/birds_icon.gif"><font size="5" color="blue"> Birds</font>');
+
+INSERT INTO product VALUES ('FI-SW-01','FISH','Angelfish','<image src="../images/fish1.gif">Salt Water fish from Australia');
+INSERT INTO product VALUES ('FI-SW-02','FISH','Tiger Shark','<image src="../images/fish4.gif">Salt Water fish from Australia');
+INSERT INTO product VALUES ('FI-FW-01','FISH', 'Koi','<image src="../images/fish3.gif">Fresh Water fish from Japan');
+INSERT INTO product VALUES ('FI-FW-02','FISH', 'Goldfish','<image src="../images/fish2.gif">Fresh Water fish from China');
+INSERT INTO product VALUES ('K9-BD-01','DOGS','Bulldog','<image src="../images/dog2.gif">Friendly dog from England');
+INSERT INTO product VALUES ('K9-PO-02','DOGS','Poodle','<image src="../images/dog6.gif">Cute dog from France');
+INSERT INTO product VALUES ('K9-DL-01','DOGS', 'Dalmation','<image src="../images/dog5.gif">Great dog for a Fire Station');
+INSERT INTO product VALUES ('K9-RT-01','DOGS', 'Golden Retriever','<image src="../images/dog1.gif">Great family dog');
+INSERT INTO product VALUES ('K9-RT-02','DOGS', 'Labrador Retriever','<image src="../images/dog5.gif">Great hunting dog');
+INSERT INTO product VALUES ('K9-CW-01','DOGS', 'Chihuahua','<image src="../images/dog4.gif">Great companion dog');
+INSERT INTO product VALUES ('RP-SN-01','REPTILES','Rattlesnake','<image src="../images/snake1.gif">Doubles as a watch dog');
+INSERT INTO product VALUES ('RP-LI-02','REPTILES','Iguana','<image src="../images/lizard1.gif">Friendly green friend');
+INSERT INTO product VALUES ('FL-DSH-01','CATS','Manx','<image src="../images/cat2.gif">Great for reducing mouse populations');
+INSERT INTO product VALUES ('FL-DLH-02','CATS','Persian','<image src="../images/cat1.gif">Friendly house cat, doubles as a princess');
+INSERT INTO product VALUES ('AV-CB-01','BIRDS','Amazon Parrot','<image src="../images/bird2.gif">Great companion for up to 75 years');
+INSERT INTO product VALUES ('AV-SB-02','BIRDS','Finch','<image src="../images/bird1.gif">Great stress reliever');
+
+INSERT INTO supplier VALUES (1,'XYZ Pets','AC','600 Avon Way','','Los Angeles','CA','94024','212-947-0797');
+INSERT INTO supplier VALUES (2,'ABC Pets','AC','700 Abalone Way','','San Francisco ','CA','94024','415-947-0797');
+
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-1','FI-SW-01',16.50,10.00,1,'P','Large');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-2','FI-SW-01',16.50,10.00,1,'P','Small');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-3','FI-SW-02',18.50,12.00,1,'P','Toothless');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-4','FI-FW-01',18.50,12.00,1,'P','Spotted');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-5','FI-FW-01',18.50,12.00,1,'P','Spotless');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-6','K9-BD-01',18.50,12.00,1,'P','Male Adult');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-7','K9-BD-01',18.50,12.00,1,'P','Female Puppy');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-8','K9-PO-02',18.50,12.00,1,'P','Male Puppy');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-9','K9-DL-01',18.50,12.00,1,'P','Spotless Male Puppy');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-10','K9-DL-01',18.50,12.00,1,'P','Spotted Adult Female');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-11','RP-SN-01',18.50,12.00,1,'P','Venomless');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-12','RP-SN-01',18.50,12.00,1,'P','Rattleless');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-13','RP-LI-02',18.50,12.00,1,'P','Green Adult');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-14','FL-DSH-01',58.50,12.00,1,'P','Tailless');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-15','FL-DSH-01',23.50,12.00,1,'P','With tail');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-16','FL-DLH-02',93.50,12.00,1,'P','Adult Female');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-17','FL-DLH-02',93.50,12.00,1,'P','Adult Male');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-18','AV-CB-01',193.50,92.00,1,'P','Adult Male');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-19','AV-SB-02',15.50, 2.00,1,'P','Adult Male');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-20','FI-FW-02',5.50, 2.00,1,'P','Adult Male');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-21','FI-FW-02',5.29, 1.00,1,'P','Adult Female');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-22','K9-RT-02',135.50, 100.00,1,'P','Adult Male');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-23','K9-RT-02',145.49, 100.00,1,'P','Adult Female');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-24','K9-RT-02',255.50, 92.00,1,'P','Adult Male');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-25','K9-RT-02',325.29, 90.00,1,'P','Adult Female');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-26','K9-CW-01',125.50, 92.00,1,'P','Adult Male');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-27','K9-CW-01',155.29, 90.00,1,'P','Adult Female');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-28','K9-RT-01',155.29, 90.00,1,'P','Adult Female');
+
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-1',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-2',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-3',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-4',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-5',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-6',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-7',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-8',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-9',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-10',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-11',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-12',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-13',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-14',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-15',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-16',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-17',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-18',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-19',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-20',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-21',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-22',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-23',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-24',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-25',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-26',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-27',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-28',10000);
+