发文章
发文工具
撰写
网文摘手
文档
视频
思维导图
随笔
相册
原创同步助手
其他工具
图片转文字
文件清理
AI助手
留言交流
ibatis 返回结果集
2008-04-29 11:03
object
别名映射->实体类:resultClass
<select id=" selectAll" resultClass="AppLog">
select
ID as id,
TYPE as type,
DESCR as descr
from APP_LOG
where ID = #id#
</select>
List list = sqlMapper.queryForList("selectAll");
for (int i = 0; i < list.size(); i ) {
AppLog log = (AppLog) list.get(i);
//add your code here;
}
别名映射->Map类:resultClass
<select id=" selectAll" resultClass="java.util.HashMap">
Map map = (Map) list.get(i);
String id = (String) map.get("id");
String type = (String) map.get("type");
String descr = (String) map.get("descr");
显式映射->实体类:resultMap
<resultMap id="AppLogResult" class="AppLog">
<result property="id" column="ID"/>
<result property="type" column="Type"/>
<result property="descr" column="DESCR"/>
</resultMap>
<select id="selectAll" resultMap="AppLogResult">
select * from APP_LOG
显式映射->Map类:resultMap
<resultMap id="map-result" class="java.util.HashMap">
<select id="selectAll2" resultMap="map-result">
List list = sqlMapper.queryForList("selectAll2");
无映射
<select id="selectAll3" resultClass="java.util.HashMap">
List list = sqlMapper.queryForList("selectAll3");
String id = (String) map.get("ID");
String type = (String) map.get("TYPE");
String descr = (String) map.get("DESCR");
xml
<select id="selectxml" parameterClass="java.lang.String" resultClass="xml" xmlResultName="log">
String o=(String) sqlMapper.queryForObject("selectxml", id);
System.out.println(o);
来自: rui5327 > 《mybatis》
0条评论
发表
请遵守用户 评论公约
mybatis能否返回一个map?
其实关于key为null可不可以这样理解: 我在Dao里面这样写的 return sqlMapClient.queryForMap("User.queryForMap2", null, "userID"); 指定Map集合的key的名称为“userID”...
ibatis教程简介
如何使用Ibatis?构建基础代码ibatis的基础代码包括以下几个部分:ibatis实例配置(SqlMapConfig.xml)Pojo(PlainOrdinaryJavaObject)映射文件如何使用Ibatis?构建基础代码如何使用Ibatis?构建基础代码与H...
Ibatis2.0使用说明(二)——配置篇(4)
Ibatis2.0使用说明(二)——配置篇(4)Parameter Maps and Inline Parameters <parameterMap id="parameterMapName" [class="Author"]> <parameter property =&qu...
ibatis如何支持clob 和blob
ibatis如何支持clob 和blob 这几天仔细看了一下ibatis的文档,发现2.2后,ibatis的改变还是挺大的。BlobByteArrayTypeHandler#) </insert> <update id="update" p...
iBatis2-SqlMap的配置总结
<resultMap id="result" class="customer"> <result property="id" column="id"/> <result property="name" column=...
使用 ibatis 处理复杂对象数据关系的实例 - ArtCode的个人空间 - ITPUB个人空间 - powered by X-Space
<typeAlias alias="Bank" type="com.example.domain.Bank"/> <resultMap id="getBankResult" class="Bank"> <result property="id"...
iBatis批量处理 多表关联查询
--><insert id="customPO_insert" parameterClass="customPO">INSERT INTO $moduleTable$ (parentID<iterate property="fieldValueList" prepend=",&q...
MyBatis注解Annotation介绍及Demo
2,数据库表Blog:01.DROP TABLE IF EXISTS `blog`;02.CREATE TABLE `blog` (03.`id` int(10) NOT NULL auto_increment,04.`title` varchar(200) NOT NULL,05.`date` varchar(50) NOT NULL,06.`authern...
Mybatis调用存储过程返回多个结果集
Mybatis调用存储过程返回多个结果集。Map<String,Object> map=new HashMap<String, Object>();//取得返回的结果集 List<List<?>> results = orderDao.getOrders(map); //第一...
微信扫码,在手机上查看选中内容