下面介绍的是mybatis简单的动态选择性插入
<?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.kmnfsw.dao.SY_PeopleMapper" >
<resultMap id="BaseResultMap" type="com.kmnfsw.entity.PeopleInforMationEntity" >
<id column="PeopleNo" property="peopleno" jdbcType="VARCHAR" />
<result column="Password" property="password" jdbcType="VARCHAR" />
<result column="Name" property="name" jdbcType="VARCHAR" />
<result column="JobId" property="jobid" jdbcType="VARCHAR" />
<result column="PoOrganizeAId" property="poaid" jdbcType="VARCHAR" />
<result column="PoOrganizeBId" property="pobid" jdbcType="VARCHAR" />
<result column="PoOrganizeCId" property="pocid" jdbcType="VARCHAR" />
<result column="PoOrganizeDId" property="podid" jdbcType="VARCHAR" />
<result column="PoOrganizeEId" property="poeid" jdbcType="VARCHAR" />
<result column="Phone" property="phone" jdbcType="VARCHAR" />
<result column="Email" property="email" jdbcType="VARCHAR" />
<result column="Sex" property="sex" jdbcType="VARCHAR" />
<result column="Address" property="address" jdbcType="VARCHAR" />
<result column="Educational" property="educational" jdbcType="VARCHAR" />
<result column="Specialty" property="specialty" jdbcType="VARCHAR" />
<result column="WorkNo" property="workno" jdbcType="VARCHAR" />
<result column="Graduation" property="graduation" jdbcType="DATE" />
<result column="GraduateSchool" property="graduateschool" jdbcType="VARCHAR" />
</resultMap>
<insert id="insertPeople" parameterType="com.kmnfsw.entity.PeopleInforMationEntity" >
insert into SY_People
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="peopleno != null" >
PeopleNo,
</if>
<if test="password != null" >
Password,
</if>
<if test="name != null" >
Name,
</if>
<if test="jobid != null" >
JobId,
</if>
<if test="poaid != null" >
PoOrganizeAId,
</if>
<if test="pobid != null" >
PoOrganizeBId,
</if>
<if test="pocid != null" >
PoOrganizeCId,
</if>
<if test="podid != null" >
PoOrganizeDId,
</if>
<if test="poeid != null" >
PoOrganizeEId,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="peopleno != null" >
#{peopleno,jdbcType=VARCHAR},
</if>
<if test="password != null" >
#{password,jdbcType=VARCHAR},
</if>
<if test="name != null" >
#{name,jdbcType=VARCHAR},
</if>
<if test="jobid != null" >
#{jobid,jdbcType=VARCHAR},
</if>
<if test="poaid != null" >
#{poaid,jdbcType=VARCHAR},
</if>
<if test="pobid != null" >
#{pobid,jdbcType=VARCHAR},
</if>
<if test="pocid != null" >
#{pocid,jdbcType=VARCHAR},
</if>
<if test="podid != null" >
#{podid,jdbcType=VARCHAR},
</if>
<if test="poeid != null" >
#{poeid,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<insert id="insertSY_Base" parameterType="com.kmnfsw.entity.PeopleInforMationEntity" >
insert into SY_PO_BaseInfo
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="peopleno != null" >
PeopleNo,
</if>
<if test="phone != null" >
Phone,
</if>
<if test="email != null" >
Email,
</if>
<if test="sex != null" >
Sex,
</if>
<if test="address != null" >
Address,
</if>
<if test="educational != null" >
Educational,
</if>
<if test="specialty != null" >
Specialty,
</if>
<if test="workno != null" >
WorkNo,
</if>
<if test="graduation != null" >
Graduation,
</if>
<if test="graduateschool !=null" >
GraduateSchool,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="peopleno != null" >
#{peopleno,jdbcType=VARCHAR},
</if>
<if test="phone != null" >
#{phone,jdbcType=VARCHAR},
</if>
<if test="email != null" >
#{email,jdbcType=VARCHAR},
</if>
<if test="sex != null" >
#{sex,jdbcType=VARCHAR},
</if>
<if test="address != null" >
#{address,jdbcType=VARCHAR},
</if>
<if test="educational != null" >
#{educational,jdbcType=VARCHAR},
</if>
<if test="specialty != null" >
#{specialty,jdbcType=VARCHAR},
</if>
<if test="workno != null" >
#{workno,jdbcType=VARCHAR},
</if>
<if test="graduation != null" >
#{graduation,jdbcType=DATE},
</if>
<if test="graduateschool !=null" >
#{graduateschool,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updatePeople" parameterType="com.kmnfsw.entity.PeopleInforMationEntity" >
update SY_People
<set >
<if test="password != null" >
Password = #{password,jdbcType=VARCHAR},
</if>
<if test="name != null" >
Name = #{name,jdbcType=VARCHAR},
</if>
<if test="jobid != null" >
JobId = #{jobid,jdbcType=VARCHAR},
</if>
<if test="poaid != null" >
PoOrganizeAId = #{poaid,jdbcType=VARCHAR},
</if>
<if test="pobid != null" >
PoOrganizeBId = #{pobid,jdbcType=VARCHAR},
</if>
<if test="pocid != null" >
PoOrganizeCId = #{pocid,jdbcType=VARCHAR},
</if>
<if test="podid != null" >
PoOrganizeDId = #{podid,jdbcType=VARCHAR},
</if>
<if test="poeid != null" >
PoOrganizeEId = #{poeid,jdbcType=VARCHAR},
</if>
</set>
where PeopleNo = #{peopleno,jdbcType=VARCHAR}
</update>
<update id="updateSY_Base" parameterType="com.kmnfsw.entity.PeopleInforMationEntity" >
update SY_PO_BaseInfo
<set >
<if test="phone != null" >
Phone = #{phone,jdbcType=VARCHAR},
</if>
<if test="email != null" >
Email = #{email,jdbcType=VARCHAR},
</if>
<if test="sex != null" >
Sex = #{sex,jdbcType=VARCHAR},
</if>
<if test="address != null" >
Address = #{address,jdbcType=VARCHAR},
</if>
<if test="educational != null" >
Educational = #{educational,jdbcType=VARCHAR},
</if>
<if test="specialty != null" >
Specialty = #{specialty,jdbcType=VARCHAR},
</if>
<if test="workno != null" >
WorkNo = #{workno,jdbcType=VARCHAR},
</if>
<if test="graduation != null" >
Graduation = #{graduation,jdbcType=DATE},
</if>
<if test="graduateschool !=null" >
GraduateSchool = #{graduateschool,jdbcType=VARCHAR},
</if>
</set>
where PeopleNo = #{peopleno,jdbcType=VARCHAR}
</update>
</mapper>