<?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">
<mapper namespace="com.lijunyang.mapper.userMapper">
<resultMap type="user" id="user">
<id column="userId" property="userId" />
<result column="userName" property="userName"/>
<result column="password" property="password"/>
<result column="Telephone" property="telephone"/>
<result column="email" property="email"/>
<result column="createTime" property="createTime"/>
<result column="updatePasswordTime" property="updatePasswordTime"/>
</resultMap>
<select id="selectUser" parameterType="java.util.Map" resultMap="user">
select * from user u where u.userName = #{userName}
</select>
<insert id="userInsert" parameterType="user">
<!--
selectKey 是做主键返回的
keyProperty 接受主键返回的属性
order: "AFTER" 是mysql中使用的 "BEFORE" 指的是顺序,生成主键的顺序 自增序列
resultType 返回主键的数据类型
生成主键的sql select LAST_INSERT_ID()
-->
<selectKey keyProperty="userId" order="AFTER" resultType="java.lang.Integer">
<!-- 此处是mysql的写法,oracle中不一样 -->
select LAST_INSERT_ID()
</selectKey>
insert into user (userId, userName, password, Telephone, email, createTime, updatePasswordTime)
value(#{userId}, #{userName}, #{password}, #{telephone}, #{email}, #{createTime} ,#{updatePasswordTime})
</insert>
</mapper>