mybatis返回list很智能很简答的,只需要配置resultmap进行类型转换,你dao方法直接写返回值list<对应的object>就行了啊

dao方法
public List<User> selectSimpleMulti(Map<String, Object> params){
if(params == null){
params = new HashMap<String, Object>();
} return dao.queryList(mapper+ "selectSimpleMulti", params);
}

对应的mapper.xml配置sql语句

<resultMap id="BaseResultMap" type="User" extends="SimpleResultMap">
<id property="uid" column="uid" /> <result property="unionid" column="unionid"/>
<result property="openid" column="openid"/>
<result property="age" column="age"/>
<result property="birthday" column="birthday"/>
<result property="sex" column="sex"/>
<result property="phone" column="phone"/>
<result property="email" column="email"/>
<result property="qq" column="qq"/>
<result property="wechat" column="wechat"/>
<result property="province" column="province"/>
<result property="city" column="city"/>
<result property="country" column="country"/>
<result property="channel" column="channel"/>
<result property="password" column="password"/> <!-- SimpleResultMap 中已经有
<result property="nickname" column="nickname"/>
<result property="headimgurl" column="headimgurl"/>
<result property="appid" column="appid"/>
<result property="password" column="password"/>
-->
<result property="backgroundimg" column="backgroundimg"/>
<result property="description" column="description"/>
<result property="createTime" column="create_time"/> </resultMap> <resultMap id="SimpleResultMap" type="User">
<id property="uid" column="uid" />
<result property="nickname" column="nickname"/>
<result property="headimgurl" column="headimgurl"/>
</resultMap>

<select id="selectSimpleMulti" resultMap="SimpleResultMap">
select uid, nickname, headimgurl from tbl_user where
<trim prefixOverrides="and">
<if test="phone != null">
and phone = #{phone}
</if>
<if test="uidList != null and uid == null">
and uid in (
<foreach collection="uidList" item="item" separator=",">
#{item}
</foreach>
)
</if>
<if test="uidList == null and uid != null">
and uid = #{uid}
</if>
</trim>
</select>

mybatis返回list很智能很简答的,只需要配置resultmap进行类型转换,你dao方法直接写返回值list<对应的object>就行了啊的更多相关文章

  1. php实现中文转数字,实现方式很智能很php

    分享一个辅助函数,使用php尽可能识别出字符串中的数字,实现效果如下. 1 2 3 4 5 6 7 8 9 echo checkNatInt('九百六十万'); //普通中文数字,9600000 ec ...

  2. linux系统运维面试题简答

    1.     简述常用高可用技术 解答: Keepalived:Keepalived是一个保证集群高可用的服务软件,用来防止单点故障,使用VRRP协议实现.在master和backup之间通过mast ...

  3. Solr调研总结(很详细很全面)

    Solr调研总结 开发类型 全文检索相关开发 Solr版本 4.2 文件内容 本文介绍solr的功能使用及相关注意事项;主要包括以下内容:环境搭建及调试;两个核心配置文件介绍;维护索引;查询索引,和在 ...

  4. Makefile经典教程(一个很棒很清晰的讲解)【转】

    转自:https://blog.csdn.net/seven_amber/article/details/70216216 该篇文章为转载,是对原作者系列文章的总汇加上标注. 支持原创,请移步陈浩大神 ...

  5. 简答一波 HashMap 常见八股面试题 —— 算法系列(2)

    请点赞,你的点赞对我意义重大,满足下我的虚荣心. Hi,我是小彭.本文已收录到 GitHub · Android-NoteBook 中.这里有 Android 进阶成长知识体系,有志同道合的朋友,关注 ...

  6. 有一个很大的整数list,需要求这个list中所有整数的和,写一个可以充分利用多核CPU的代码,来计算结果(转)

    引用 前几天在网上看到一个淘宝的面试题:有一个很大的整数list,需要求这个list中所有整数的和,写一个可以充分利用多核CPU的代码,来计算结果.一:分析题目 从题中可以看到“很大的List”以及“ ...

  7. Unix / 类 Unix shell 中有哪些很酷很冷门很少用很有用的命令?(转)

    著作权归作者所有. 商业转载请联系作者获得授权,非商业转载请注明出处. 作者:孙立伟 链接:http://www.zhihu.com/question/20140085/answer/14107336 ...

  8. Java 实现简答的单链表的功能

    作者:林子木  博客网址:http://blog.csdn.net/wolinxuebin 參考网址:http://blog.csdn.net/sunsaigang/article/details/5 ...

  9. 【转】【很全很新】C3P0 连接池和 DBUtils 配合事务使用总结

    [转]https://blog.csdn.net/guozhaohui628/article/details/84793028 很久没用原生连接池,最近想写个小功能,结果发现很多地方不太懂,然后网上搜 ...

随机推荐

  1. Objective - c Chapter 1 -2 Hello world

    Objective - c   Chapter 1  Hello world 1.1 1.2.On the Welcome screen, click "Create a new Xcode ...

  2. DLL线程中坑爹的Synchronize?

    1, 缘起 某次开发语音对讲windows程序,采用delphi语言,及delphix的TDXSound控件. DXSound提供了TSoundCaptureStream类,可以实现指定频率.位数.声 ...

  3. 重构28-Rename boolean method(重命名布尔方法)

    你也可以说这并不是一个真正的重构,因为方法实际上改变了,但这是一个灰色地带,可以开放讨论.一个拥有大量布尔类型参数的方法将很快变得无法控制,产生难以预期的行为.参数的数量将决定分解的方法的数量.来看看 ...

  4. nginx负载均衡浅析

    熟悉Nginx的小伙伴都知道,Nginx是一个非常好的负载均衡器.除了用的非常普遍的Http负载均衡,Nginx还可以实现Email,FastCGI的负载均衡,甚至可以支持基于Tcp/UDP协议的各种 ...

  5. select * from a, b的意思

    其结果中总记录数为a表记录数乘以b表记录数,a的每条记录都会重复列出b记录总数次 很多晦涩的sql都要通过测试具体的数据来理解

  6. BotFramework学习-01

    微软在Build2016大会上表示,未来将是一个充满聊天机器人的世界,为此他们推出了微软Bot Framework,能够允许任何人制作自己的聊天机器人,微软则提供“cognitive microser ...

  7. mysql 查看存储过程 并导出

    查询数据库中的存储过程 select * from mysql.proc where db = dbName and `type` = 'PROCEDURE' show procedure statu ...

  8. make、makefile

    http://blog.csdn.net/wed110/article/details/34853475 什么是makefile?或许很多Winodws的程序员都不知道这个东西,因为那些Windows ...

  9. 小程序input自动聚焦拉起键盘

    微信官方提供了两种自动聚焦的方法 1,auto-focus 接受boolean值:默认为false:只需设置为true即可 自动聚焦,拉起键盘:不过官方的提示即将废弃,所以能不用还是不要用 2,foc ...

  10. 原生javascript实现call、apply和bind的方法

    var context = {id: 12}; function fun (name, age) { console.log(this.id, name, age) } bind bind() 方法会 ...