常用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>
上一篇:Linux上有Apple的Shark吗?


下一篇:CodeForces - 621A Wet Shark and Odd and Even