src/main/java/com/luoyunfan/conf/StudentMapper.xml
(开头部分) 11KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!-- MyBatis 的真正强大在于它的映射语句,也是它的魔力所在。 SQL 映射文件有很少的几个顶级元素(按照它们应该被定义的顺序): cache
– 给定命名空间的缓存配置。 cache-ref – 其他命名空间缓存配置的引用。 resultMap – 描述如何从数据库结果集中来加载对象。
parameterMap – 已废弃!老式风格的参数映射。内联参数是首选,这个元素可能在将来被移除,这里不会记录。 sql – 可被其他语句引用的可重用语句块。
insert – 映射插入语句 update – 映射更新语句 delete – 映射删除语句 select – 映射查询语句 -->
<mapper namespace="com.luoyunfan.dao.IStudentDao">
<!--配置查询结果集和对象的映射,可以不进行配置,默认属性名和列名相同 -->
<!-- javaType 一个 Java 类的完全限定名,或一个类型别名 jdbcType JDBC类型, 仅需要对插入,更新可能为空的列进行处理 -->
<!-- 配置student表映射 -->
<resultMap id="studentMap" type="com.luoyunfan.entity.Student">
<id column="stu_zh" property="stuZh" jdbcType="VARCHAR" />
<result column="stu_pwd" property="stuPwd" jdbcType="VARCHAR" />
<result column="stu_Name" property="stuName" jdbcType="VARCHAR" />
<result column="stu_Phone" property="stuPhone" jdbcType="VARCHAR" />
</resultMap>
<select id="findOne" resultMap="studentMap">
select * from student where stu_zh = #{stuZh}
</select>
<insert id="registStu"><!-- useGeneratedKeys="true" keyProperty="stuID" -->
<selectKey keyProperty="stuZh" order="AFTER" resultType="java.lang.String">
SELECT LAST_INSERT_ID()
</selectKey>
insert into student (stu_zh,stu_pwd,stu_name,stu_phone)
values(#{stuZh},#{stuPwd},#{stuName},#{stuPhone})
</insert>
<!-- 查询所有学生 -->
<select id="stuSearchAll" resultMap="studentMap">
select * from student
</select>
<!-- 按条件查询学生 -->
<select id="searchByCondition" resultMap="studentMap">
select * from student t1
<where>
<if test="stuZh!=null">
t1.stu_zh=#{stuZh}
</if>
<if test="stuName!=null">
and t1.stu_Name=#{stuName}
</if>
</where>
</select>
<!-- 删除学生 -->
<delete id="delStu">
delete from student where stu_zh = #{stuZh}
</delete>
<update id="updateInfo">
update student set
stu_Phone = #{stuPhone},
stu_pwd =#{stuPwd}
where stu_zh = #{stuZh}
</update>
后面还有 142 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
