Skip to content

Commit

Permalink
20190610
Browse files Browse the repository at this point in the history
  • Loading branch information
keysersoze88 committed Jun 10, 2019
1 parent 1772367 commit c3ae69a
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 53 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.2.2</version>
<version>1.3.2</version>
</dependency>
<!-- mysql驱动包 -->
<dependency>
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/spring/applicationContext.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@
<property name="dataSource" ref="dataSource"/>
<property name="mapperLocations" value="classpath:sqlmap/*Mapper.xml"/>
<property name="typeAliasesPackage" value="cn.springmvc.entity" />
<property name="configuration">
<bean class="org.apache.ibatis.session.Configuration">
<property name="mapUnderscoreToCamelCase" value="true"/>
</bean>
</property>
</bean>

<!-- 在spring容器中配置mapper的扫描器产生的动态代理对象在spring的容器中自动注册,bean的id就是mapper类名(首字母小写)-->
Expand Down
104 changes: 52 additions & 52 deletions src/main/resources/sqlmap/UserinfoMapper.xml
Original file line number Diff line number Diff line change
@@ -1,68 +1,68 @@
<?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="cn.springmvc.dao.UserinfoMapper" >
<resultMap id="BaseResultMap" type="cn.springmvc.entity.Userinfo" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="name" property="name" jdbcType="VARCHAR" />
<result column="password" property="password" jdbcType="CHAR" />
</resultMap>
<sql id="Base_Column_List" >
<resultMap id="BaseResultMap" type="cn.springmvc.entity.Userinfo" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="name" property="name" jdbcType="VARCHAR" />
<result column="password" property="password" jdbcType="CHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, name, password
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from userinfo
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from userinfo
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from userinfo
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="cn.springmvc.entity.Userinfo" >
<insert id="insert" parameterType="cn.springmvc.entity.Userinfo" >
insert into userinfo (id, name, password
)
values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{password,jdbcType=CHAR}
)
</insert>
<insert id="insertSelective" parameterType="cn.springmvc.entity.Userinfo" >
insert into userinfo
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="name != null" >
name,
</if>
<if test="password != null" >
password,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="name != null" >
#{name,jdbcType=VARCHAR},
</if>
<if test="password != null" >
#{password,jdbcType=CHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="cn.springmvc.entity.Userinfo" >
update userinfo
<set >
<if test="name != null" >
name = #{name,jdbcType=VARCHAR},
</if>
<if test="password != null" >
password = #{password,jdbcType=CHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="cn.springmvc.entity.Userinfo" >
<insert id="insertSelective" parameterType="cn.springmvc.entity.Userinfo" >
insert into userinfo
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="name != null" >
name,
</if>
<if test="password != null" >
password,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="name != null" >
#{name,jdbcType=VARCHAR},
</if>
<if test="password != null" >
#{password,jdbcType=CHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="cn.springmvc.entity.Userinfo" >
update userinfo
<set >
<if test="name != null" >
name = #{name,jdbcType=VARCHAR},
</if>
<if test="password != null" >
password = #{password,jdbcType=CHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="cn.springmvc.entity.Userinfo" >
update userinfo
set name = #{name,jdbcType=VARCHAR},
password = #{password,jdbcType=CHAR}
Expand Down

0 comments on commit c3ae69a

Please sign in to comment.