![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Mybatis学习
@橘子先森
小白学代码
展开
-
Mybatis——动态sql
动态sql 1.同一个dao的方法,根据不同的条件表示不同的sql语句,主要是where部分有变化; 2.使用mybatis提供的标签,实现动态sql能力,主要使用如 if, where, foreach, sql; 3.使用动态sql的时候,dao方法的形参使用java对象; 4.多条件查询时可以使用动态sql; 一、if标签 <if test="boolean判断结果(条件)"> sql代码 </if> <!--if标签 test:使用对象的属性值原创 2020-12-24 23:13:53 · 5200 阅读 · 5 评论 -
Mybatis中输出结果的封装
Mybatis中输出结果的封装 封装输出结果: Mybatis执行sql语句,得到ResultSet,转为Java对象。 一、resultType resultType属性:在执行select时使用,作为标签是属性。 resultType:表示结果类型,mysql执行sql语句,得到java对象的类型。它的值有两种: 1、java类型的全限定名称(建议使用,可阅读性强) A) resultType表示JAVA自定义对象 /** * 查询学生 * */ Student selectStudentById(原创 2020-12-24 16:24:44 · 527 阅读 · 1 评论 -
Mybatis中 # 和 $ 占位符的区别
一、# 占位符 语法:#{字符} mybatis处理#{}使用jdbc对象是PreparedStatement对象 <select id="selectStudentById" parameterType="integer" resultType="com.itjuzi.entity.Student"> select id,name,email,age from Student where id = #{id} </select> 即mybat原创 2020-12-23 20:23:20 · 610 阅读 · 1 评论