ibatis高级查询技术的使用
来源:互联网 发布:本周重要财经数据 编辑:程序博客网 时间:2024/06/05 16:58
在ibatis中使用XML
1)XML参数
<select id="getByXmlId" resultClass="Account" parameterClass="xml">select accountId,username,password,firstname,lastname,address1,address2from Accountwhere accountId = #accountId#</select>
String parameter = "<parameter><accountId>3</accountId></parameter>";Account account = sqlMapClient.queryForObject("Account.getXmlId",parameter);
2)DOM参数
暂时不讲解,不推荐写,别计较麻烦
3)XML结果
<select id="getByIdValue<span style="font-family: Arial, Helvetica, sans-serif;">Xml</span>" resultClass="xml" xmlResultName="account">select accountId,username,password,from Accountwhere accountId = #accountId#</select>
结果:
<?xml version="1.0" encoding="UTF-8" ?><account><accountid>1</accountid><username>lmeadors</username><password>blah</password></account>
也可以返回多条记录,详解见《ibatis实战》P109
4)复杂集合
<sqlMap namspace="Ch6"><resultMap id="resultAccountInfoMap" class="org.apache.mapper2.examples.bean.AccountInfo"><result property ="account.accountId"column="accountId"/><result property ="orderList"select="Ch6.getOrderInfoList"column="accountId"/></resultMap><select id="getOrderInfoList" resultMap="ResultOrderInfoMap">select orderId from orders where accountId = #value#</select></sqlMap>
5)映射继承
<resultMap id="document" class="testdomai.Document"><result property="id" column="DOCUMENT_ID"/><result property="title" column="TITLE"/><result property="type" column="TYPE"/> <strong><discriminator column="TYPE" javaType="string"><subMap value="Book" resultMap="book"/><subMap value="Newspaper" resultMap="news"/></discriminator ></strong></resultMap><resultMap id="book" class="testdomai.Book" extends="document"><result property="pages" column="DOCUMENT PAGENUMBER"/></resultMap>
0 0
- ibatis高级查询技术的使用
- iBATIS使用之高级查询技术详解
- iBATIS高级查询技术详解
- iBATIS高级查询技术详解
- iBATIS In Action:使用高级查询技术(一)
- iBATIS In Action:使用高级查询技术(一)
- 6. 使用高级查询技术
- ibatis 使用filter查询
- ibatis使用in查询
- 高级查询技术
- iBatis的模糊查询
- ibatis的动态查询
- ibatis 的动态查询
- iBatis中使用动态查询
- iBatis中使用动态查询
- 使用ibatis做连接查询
- 注意使用Ibatis做like查询的时候SQL注入。
- 在使用ibatis实现多条件模糊查询的语句
- SignalR 学习 -HelloWorld
- POJ 2823 Sliding Window
- 队列LinkedBlockingQueue学习
- FastJSON 应用介绍
- Python学习
- ibatis高级查询技术的使用
- MDK5.14 安装过程
- 什么是java序列化,如何实现java序列化?
- 老人不能被遗忘在移动互联之外!
- memcpy的用法总结
- 2015上海酒店用品展览会
- 多核系统上的 Java 并发缺陷模式(bug patterns)
- TLD之扯淡篇(一)
- 不依赖框架的文件下载