java
<!--經過帳號查詢用戶:一個參數用parameterType="java.lang.String"-->
<select id="findByUserCode" parameterType="java.lang.String" resultType="com.ssm.model.User">
SELECT * FROM t_user WHERE UserCode = #{userCode} OR Phone = #{userCode}
</select>
<!--經過帳號和密碼查詢用戶:多個參數用parameterType="map"-->
<select id="findByUserCodeAndPassword" parameterType="map" resultType="com.ssm.model.User">
SELECT * FROM t_user WHERE UserCode = #{userCode} AND loginPassword = #{password}
</select>
resultMap須要先自定義定義map,指定id,而後引用這個map。多數狀況用於表字段與實體類屬性不一致的狀況。id爲自定義resultMap標識,type爲實體類,property爲實體類屬性名,column爲表字段名mybatis
<resultMap type="com.ssm.model.Talk" id="tab_talk">
<id property="ID" column="ID"/>
<result property="TALK_NAME" column="TalkName"/>
<result property="ICO" column="Ico"/>
<result property="OWNER" column="Owner"/>
<result property="IS_MESSAGE_REMIND" column="IsMessageRemind"/>
<result property="IS_MESSAGE_ACCEPT" column="IsMessageAccept"/>
<result property="CREATE_MAN" column="CreateMan"/>
<result property="CREATE_DATE" column="CreateDate"/>
<result property="MODIFY_MAN" column="ModifyMan"/>
<result property="MODIFY_DATE" column="ModifyDate"/>
<result property="IS_USE" column="IsUse"/>
<result property="REMARK" column="Remark"/>
</resultMap>
<!--經過帳號查詢用戶-->
<select id="findAll" resultMap="tab_talk">
SELECT * FROM t_talk
</select>