alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Spring Framework example source code file (Item.xml)

This example Spring Framework source code file (Item.xml) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Spring Framework tags/keywords

doctype, item, map, memory, memory, public, sql, sql, utf-8, utf-8, weak, weak

The Spring Framework Item.xml source code

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd">

<sqlMap namespace="Item">

  <cacheModel id="oneDayItem" type="MEMORY">
    <flushInterval hours="24"/>
    <property name="reference-type" value="WEAK"/>
  </cacheModel>

  <cacheModel id="oneDayQuantity" type="MEMORY">
    <flushInterval hours="24"/>
    <flushOnExecute statement="updateInventoryQuantity"/>
    <property name="reference-type" value="WEAK"/>
  </cacheModel>

  <resultMap id="result" class="org.springframework.samples.jpetstore.domain.Item">
    <result property="itemId" column="itemid" columnIndex="1"/>
    <result property="listPrice" column="listprice" columnIndex="2"/>
    <result property="unitCost" column="unitcost" columnIndex="3"/>
    <result property="supplierId" column="supplier" columnIndex="4"/>
    <result property="productId" column="productid" columnIndex="5"/>
    <result property="product.productId" column="productid" columnIndex="5"/>
    <result property="product.name" column="name" columnIndex="6"/>
    <result property="product.description" column="descn" columnIndex="7"/>
    <result property="product.categoryId" column="category" columnIndex="8"/>
    <result property="status" column="status" columnIndex="9"/>
    <result property="attribute1" column="attr1" columnIndex="10"/>
    <result property="attribute2" column="attr2" columnIndex="11"/>
    <result property="attribute3" column="attr3" columnIndex="12"/>
    <result property="attribute4" column="attr4" columnIndex="13"/>
    <result property="attribute5" column="attr5" columnIndex="14"/>
  </resultMap>

  <resultMap id="result-with-quantity" class="org.springframework.samples.jpetstore.domain.Item">
    <result property="itemId" column="itemid" columnIndex="1"/>
    <result property="listPrice" column="listprice" columnIndex="2"/>
    <result property="unitCost" column="unitcost" columnIndex="3"/>
    <result property="supplierId" column="supplier" columnIndex="4"/>
    <result property="productId" column="productid" columnIndex="5"/>
    <result property="product.productId" column="productid" columnIndex="5"/>
    <result property="product.name" column="name" columnIndex="6"/>
    <result property="product.description" column="descn" columnIndex="7"/>
    <result property="product.categoryId" column="category" columnIndex="8"/>
    <result property="status" column="status" columnIndex="9"/>
    <result property="attribute1" column="attr1" columnIndex="10"/>
    <result property="attribute2" column="attr2" columnIndex="11"/>
    <result property="attribute3" column="attr3" columnIndex="12"/>
    <result property="attribute4" column="attr4" columnIndex="13"/>
    <result property="attribute5" column="attr5" columnIndex="14"/>
    <result property="quantity" column="qty" columnIndex="15"/>
  </resultMap>

  <select id="getItemListByProduct" resultMap="result">
    select
      itemid, listprice, unitcost, supplier, i.productid, name,
      descn, category, status, attr1, attr2, attr3, attr4, attr5
    from item i, product p where p.productid = i.productid and i.productid = #value#
  </select>

  <select id="getItem" resultMap="result-with-quantity">
    select
      i.itemid, listprice, unitcost, supplier, i.productid, name,
      descn, category, status, attr1, attr2, attr3, attr4, attr5, qty
    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="java.lang.Integer">
    select qty as value from inventory where itemid = #value#
  </select>

  <update id="updateInventoryQuantity">
    update inventory set qty = qty - #increment# where itemid = #itemId#
  </update>

</sqlMap>

Other Spring Framework examples (source code examples)

Here is a short list of links related to this Spring Framework Item.xml source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.