使用MyBatis 框架犯的错误
来源:互联网 发布:淘宝网经验 编辑:程序博客网 时间:2024/06/05 17:08
最近做项目,数据层使用的是MyBatis框架,在使用过程中,犯了一些错误:
resultMap和resultType书写错误导致问题
resultMap和resultType二者用法不一样:
resultType:
<select id="count" parameterType="AreaDto" resultType="java.lang.Integer"> SELECT count(*) FROM USER </select>
resultMap:
<resultMap type="com.liulanghan.Blog" id="BlogResult"> <id column="id" property="id"/> <result column="title" property="title"/> <result column="content" property="content"/> <result column="owner" property="owner"/> </resultMap> <select id="selectBlog" parameterType="int" resultMap="BlogResult"> select * from t_blog where id = #{id} </select>
resultType值可以指定很多类型,包括一个类。
jdbcType中的int类型为INTEGER
Mybatis中javaType和jdbcType对应关系:
在insert语句中,values后忘了加#{ },直接属性上去了。
<insert id="add" parameterType="EStudent"> insert into TStudent(name, age) values(#{name}, #{age})</insert>
values后面的值是相应类对应的属性值,还可以对这些属性指定jdbcType :
<insert id="insert" parameterType="com.examples.Role"> insert into role ( id,name,type) values ( #{id,jdbcType=CHAR}, #{name,jdbcType=VARCHAR}, #{type,jdbcType=CHAR} ) </insert>
0 0
- 使用MyBatis 框架犯的错误
- 使用LookupDispatchAction类犯的错误
- 使用div犯得愚蠢的错误
- 使用 libevent 容易犯的一个错误
- 使用操作符时常犯的错误
- matlab使用常犯的错误
- 使用wpa_supplicant中犯的小错误
- 使用BOOL变量犯过的错误
- 使用webpack犯过的一个错误
- MyBatis框架的使用
- MyBatis框架的使用
- MyBatis框架的使用
- Mybatis框架的使用
- MyBatis框架的使用
- 常犯的错误
- 犯过的错误
- 容易犯的错误。
- 犯过的错误
- MySQL 的CASE WHEN 语句使用说明
- CodeForces 141C Queue
- Linux
- 无需焦点的跑马灯TextView
- adb抓取log命令
- 使用MyBatis 框架犯的错误
- 在职研一英语选词填空及划线词替换习题及答案
- 梁勇2011JAVA语言程序设计基础篇第16章编程题16.11
- elastic search sql 按字段设置分词器
- java代码:new 类名(){方法定义}应该如何理解?
- 丢失控制文件恢复
- trie树的实现和应用及测试
- maven安装总结
- Statistical learning Week 1 什么是统计学习?