IBastis配置实例
生活随笔
收集整理的這篇文章主要介紹了
IBastis配置实例
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
<?xml version="1.0" encoding="utf-8" ?><sqlMap namespace="Product" xmlns="http://ibatis.apache.org/mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><alias><!--商品別名--><typeAlias alias="Product" type="OMS.DTL.Entities.Product,OMS.DTL" /><!--商品部分屬性別名--><typeAlias alias="ProductPartial" type="OMS.DTL.Entities.ProductPartial,OMS.DTL"/><!--商品查詢條件別名--><typeAlias alias="ProductQueryCondition" type="OMS.DTL.Entities.ProductQueryCondition,OMS.DTL"/></alias><!--結(jié)果映射--><resultMaps><resultMap id="ProductPartial" class="ProductPartial"><result property="ProductID" column="ProductID"/><result property="ProductName" column="ProductName"/><result property="QuantityPerUnit" column="QuantityPerUnit"/><result property="UnitPrice" column="UnitPrice" /><result property="UnitsInStock" column="UnitsInStock"/></resultMap></resultMaps><statements><!--查詢所有商品--><select id="SelectAllProduct" resultClass="Product">SELECT [ProductID],[ProductName],[SupplierID],[CategoryID],[QuantityPerUnit],[UnitPrice],[UnitsInStock],[UnitsOnOrder],[ReorderLevel],[Discontinued]FROM [Products]</select><!--根據(jù)商品ID查詢商品--><select id="SelectProductByProductID" parameterClass="int" resultClass="Product" extends="SelectAllProduct">WHERE ProductID=#PorductID#</select><!--獲取所有產(chǎn)品的部分信息--><select id="SelectAllProductPartial" resultMap="ProductPartial">SELECT [ProductID],[ProductName],[SupplierID],[CategoryID],[QuantityPerUnit],[UnitPrice],[UnitsInStock],[UnitsOnOrder],[ReorderLevel],[Discontinued]FROM [Products]</select><!--通過兩個條件或的關(guān)系查找--><!--通過字典傳值--><select id="SelectProductByIDOrName" parameterClass="System.Collections.IDictionary" resultClass="Product" extends="SelectAllProduct">WHERE ProductID=#ProductID# OR ProductName=#ProductName# </select><!--通過類傳值--><select id="SelectProductBySupplierIDOrCategoryID" parameterClass="ProductQueryCondition" resultClass="Product" extends="SelectAllProduct">WHERE SupplierID=#SupplierID# OR CategoryID=#CategoryID#</select><!--插入操作--><insert id="Insert" parameterClass="Product">INSERT INTO [Products]([ProductName],[SupplierID],[CategoryID],[QuantityPerUnit],[UnitPrice],[UnitsInStock],[UnitsOnOrder],[ReorderLevel],[Discontinued])VALUES(#ProductName#,#SupplierID#,#CategoryID#,#QuantityPerUnit#,#UnitPrice#,#UnitsInStock#,#UnitsOnOrder#,#ReorderLevel#,#Discontinued#)<!--獲取自增列ID--><selectKey resultClass="int" type="post" property="ProductID" >select @@IDENTITY as value</selectKey></insert><!--更新操作--><update id="Update" parameterClass="System.Collections.IDictionary">update Productsset ProductName = #ProductName#where ProductID = #ProductID#</update><!--刪除操作--><delete id="Delete" parameterClass="int">Delete From ProductsWhere ProductID=#ProductID#</delete></statements></sqlMap>
轉(zhuǎn)載于:https://www.cnblogs.com/wjchang/archive/2013/01/24/3671548.html
總結(jié)
以上是生活随笔為你收集整理的IBastis配置实例的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Android 条码扫描程序源码
- 下一篇: 仿ireader书架