mybatis 中resultType与resultMap区别
来源:互联网 发布:001a航母 知乎 编辑:程序博客网 时间:2024/05/16 06:52
mybatis中要返回如下对象的List集合:
public class Host {private String hostType;private String hostAddr;public String getHostType() {return hostType;}public void setHostType(String hostType) {this.hostType = hostType;}public String getHostAddr() {return hostAddr;}public void setHostAddr(String hostAddr) {this.hostAddr = hostAddr;}}
如果对应的表结构是:
CREATE TABLE `host` ( `host_type` varchar(32) NOT NULL COMMENT '主机类型', `host_addr` varchar(128) NOT NULL COMMENT '主机地址',)
用resultMap返回xml中应当这样写:
<resultMap type="net.flyingfat.common.biz.domain.Host" id="hostResult"> <result column="host_type" property="hostType"/> <result column="host_addr" property="hostAddr"/> </resultMap> <select id="getHost" resultMap="hostResult"> SELECT * FROM host</select>用resultType返回,xml中仅仅改为
<select id="getHost" resultType="net.flyingfat.common.biz.domain.Host"> SELECT * FROM host</select>
是不够的,表结构也要改为
CREATE TABLE `host` ( `hostType` varchar(32) NOT NULL COMMENT '主机类型', `hostAddr` varchar(128) NOT NULL COMMENT '主机地址')
0 0
- mybatis 中resultType与resultMap区别
- mybatis Resultmap 与 ResultType 区别
- MyBatis中 resultType与resultMap
- Mybatis中resultMap和resultType使用联系与区别
- Mybatis中输出映射-resultType与resultMap的区别
- mybatis中的resultMap与resultType的区别
- mybatis中resultMap和resultType的区别
- MyBatis中ResultMap和ResultType的区别
- MyBatis中resultType和resultMap的区别
- mybatis中resultmap和resulttype区别
- mybatis中resulttype和resultmap的区别
- MyBatis中resultType和resultMap的区别
- mybatis 中resulttype 与resultmap用法
- resultType与resultMap区别
- Mybatis中的resultType与resultMap
- Mybatis中resultMap和resultType
- Mybatis中resultMap和resultType
- MyBatis中关于resultType和resultMap的区别
- ReactiveCocoa操作方法(过滤,秩序,时间,重复)
- 算法思想系列--分治策略(Divide-Conquer-Combine)(待补充)
- LeetCode-78.Subsets
- POJ1287 Networking
- SonarQube
- mybatis 中resultType与resultMap区别
- ACM--田忌赛马--贪心--HDOJ 1052--Tian Ji -- The Horse Racing
- next-permutation
- linux的源
- 非root用户安装python第三方模块
- sizeof ()求指针和数组时的不同
- 求两个数的最大公约数
- HTTP协议总结
- 输出一个字符串遇见‘ \0 ’停止并返回字符串字符的个数