常用SQL语句写法(一)

<resultMap id="userResult" type="com.cloudwalk.shark.model.User">
<id property="id" column="ID" jdbcType="INTEGER"></id>
<result property="userName" column="user_name" jdbcType="VARCHAR"></result>
</resultMap>

<insert id="insertUser" parameterType="com.cloudwalk.shark.model.User">
INSERT INTO
t_shark_user(ID,USER_NAME)
VALUES
(
#{id},#{userName}
)
</insert>

<select id="findUserByName" parameterType="java.lang.String" resultMap="userResult">
select id,user_name as userName from t_shark_user
where 1=1
<if test=" _parameter !=null and _parameter !='' " >
and user_name = #{name,jdbcType=VARCHAR}
</if>
</select>

<select id="queryUserByName" parameterType="java.util.ArrayList" resultMap="userResult">
select id,user_name as userName from t_shark_user
where user_name in
<if test=" list !=null and list.size>0 !='' " >
<foreach collection="list" item="userName" index="index" open="(" close=")" separator=",">
#{userName}
</foreach>
</if>
</select>
posted @ 2019-05-08 19:39  龙X  阅读(1187)  评论(0编辑  收藏  举报