mapping sample

==-sqlMap.xml==
--------------
<'insert id="statementName" parameterClass="example.Product">
INSERT INTO PRODUCT (PRD_ID, PRD_DESCRIPTION, PRICE)VALUES (#id#, #description#, #price#)
<'/insert>
--------------
<'parameterMap id="insert-product-param"class="example.Product">
<'parameter property="id"/>
<'parameter property="description"/>
<'/parameterMap>
<'insert id="insertProduct" parameterMap="insert-product-param">
INSERT INTO PRODUCT (PRD_ID, PRD_DESCRIPTION) VALUES (?,?)
<'/insert>
--------------
<'select id="getPerson"
parameterClass="java.lang.Integer"
resultClass="examples.Person">
SELECT
ID AS id,
FIRST_NAME AS firstName,
LAST_NAME AS lastName,
BIRTH_DATE AS birthDate,
WEIGHT_KG AS weightInKilograms,
HEIGHT_M AS heightInMeters
FROM
PERSONWHERE ID = #value#
<'/select>
--------------
<'resultMap id="get-product-result" class="example.Product">
<'result property="id" column="PRD_ID"/>
<'result property="description" column="PRD_DESCRIPTION"/>
<'/resultMap>
<'select id="getProduct" resultMap="get-product-result">
SELECT * FROM PRODUCT
<'/select>
--------------
<'select id="getBook"
parameterClass="sample.Book"
resultClass="sample.Book">
SELECT ISBN AS isbn, TITLE AS title FROM BOOK WHERE ISBN = #isbn#
<'/select>
<'select id="getBooks"
resultClass="sample.Book">
SELECT ISBN AS isbn, TITLE AS title FROM BOOK
<'/select>
--------------
<'resultMap id="get-product-result"
class="example.Product">
<'result property="id" column="PRD_ID"/>
<'result property="description" column="PRD_DESCRIPTION"/>
<'result property="category.id" column="CAT_ID"/>
<'result property="category.description" column="CAT_DESCRIPTION"/>
<'/resultMap>
<'select id="getProduct" parameterClass="java.lang.Integer" resultMap="get-product-result">
SELECT *FROM PRODUCT, CATEGORYWHERE PRD_CAT_ID=CAT_IDAND PRD_ID = #value#
<'/select>
--------------
<'cacheModelid="product-cache"
type ="LRU"
readOnly="true"
serialize="false">
<'flushIntervalhours="24"/>
<'flushOnExecutestatement="insertProduct"/>
<'flushOnExecutestatement="updateProduct"/>
<'flushOnExecutestatement="deleteProduct"/>
<'property name="cache-size" value="1000" />
<'/cacheModel>
<'select id="getProductList" cacheModel="product-cache" resultClass="...">
SELECT * FROM PRODUCT WHERE PRD_CAT_ID = #value#
<'/select>
--------------
<'select id="dynamicGetAccountList"resultMap="account-result" >
SELECT * FROM ACCOUNT
<'isGreaterThanproperty="id" compareValue="0">
WHERE ACC_ID = #id#
<'/isGreaterThan>
ORDER BY ACC_LAST_NAME
<'/select>
--------------
<'select id="someName"resultMap="account-result" >
SELECT * FROM ACCOUNT<'dynamic prepend="WHERE">
<'isGreaterThanprepend="AND" property="id“compareValue="0">
ACC_ID = #id#
<'/isGreaterThan>
<'isNotNullprepend="AND" property="lastName">
ACC_LAST_NAME = #lastName#
<'/isNotNull>
<'/dynamic>
ORDER BY ACC_LAST_NAME
<'/select>
<'select id="someName"resultMap="account-result" >
SELECT * FROM ACCOUNT
<'dynamic prepend="WHERE">
<'isGreaterThanprepend="AND" property="id“compareValue="0">
ACC_ID = #id#
<'/isGreaterThan>
<'isNotNullprepend="AND" property="lastName">
ACC_LAST_NAME = #lastName#
<'/isNotNull>
<'/dynamic>
ORDER BY ACC_LAST_NAME
<'/select>
--------------
<'iterate prepend="AND"property="userNameList"open="("close=")"conjunction="OR">
USERNAME = #userNameList[]#
<'/iterate>
--------------
<'parameterMapid="insert-product-param" class="com.domain.Product">
<'parameter property="id" jdbcType="NUMERIC"/>
<'parameter property="description" jdbcType="VARCHAR"/>
<'/parameterMap>
--------------
<'insert id=”insertProduct”parameterClass=”sample.Product”>
INSERT INTO PRODUCT (PRD_ID, PRD_DESCRIPTION)VALUES (#id:NUMERIC#, #description:VARCHAR#)
<'/insert>
--------------
<'parameterMapid="insert-product-param" class="sample.Product">
<'parameter property=“id”jdbcType=“NUMERIC”nullValue="-9999999"/>
<'parameter property="description" jdbcType="VARCHAR" nullValue="NO_ENTRY"/>
<'/parameterMap>
--------------
<'insert id="insertProduct" parameterClass="sample.Product">
INSERT INTO PRODUCT
(PRD_ID, PRD_DESCRIPTION)
VALUES
(#id:NUMERIC:-999999#, #description:VARCHAR:NO_ENTRY#)
<'/insert>
--------------
<'insert id="insertProduct-ORACLE" parameterClass="sample.Product">
<'selectKeyresultClass="java.lang.Integer" >
SELECT STOCKIDSEQUENCE.NEXTVAL AS IDFROM DUAL
<'/selectKey>
INSERT INTO PRODUCT
(PRD_ID,PRD_DESCRIPTION)
VALUES
(#id#,#description#)
<'/insert>
--------------
<'parameterMapid="swapParameters" class=“java.util.Map" >
<'parameter property="email1" jdbcType="VARCHAR“javaType="java.lang.String" mode="INOUT"/>
<'parameter property="email2" jdbcType="VARCHAR“javaType="java.lang.String" mode="INOUT"/>
<'/parameterMap>
<'procedure id="swapEmailAddresses" parameterMap="swapParameters" >
{CALL SWAP_EMAIL_ADDRESS (?, ?)}
<'/procedure>
--------------



2007-10-11 06:01 : __orm__ibatis : コメント : 0 : トラックバック : 0 :
コメントの投稿
非公開コメント

« next  ホーム  prev »

search

ad



counter


tag cloud

category cloud