定义别名
在Mybatis 的全局配置文件中给返回对象值 全限定类型对象类名
第一种方式:
给类下别名
<typeAliases>
<typeAlias type="com.demo.Student" alias="stu" />
</typeAliases>
第二种方式:
<typeAliases>
<package type="com.demo" />
</typeAliases>
给包下别名 这样这个包下的所有类的别名就是他的类名 而不用写全限定类名
返回类型
Mybatis中的返回类型是多种多样的
resultType="Student"
体现在对应接口类的xml文件中
resultType就是要返回的对象 一般是类的全限定名称
动态sql
<if> <where> <foreach>
<if>
<if:test=“使用参数java对象的属性值作为判断条件” 语法: 属性值=xxx>
<if test= "age>0">
age > #{age}
</if>
<where>
<where>
<if test= "age>0">
age > #{age}
</if>
</where>
<where>语句自动拼接多个if语句
<foreach>在sql语句中拼接遍历的数组、集合。