mapper.xml中返回值型別
阿新 • • 發佈:2021-01-07
技術標籤:碼農之路
因為兩次都錯在這個上面上,所以還是記錄一下。。。。
resultType是直接表示返回型別的,比如Integer,String, List<Integer>也是一樣,resultMap則是對外部ResultMap的引用
例如:
<select id="selectByStatus" resultType="java.lang.Integer" parameterType="com.meihui.learning.viewmodel.admin.question.QuestionStatusVM"> SELECT t_question.id FROM t_question LEFT JOIN t_question_status on t_question_status.question_id = t_question.id <where> and t_question.deleted = 0 <if test="questionType != null"> and t_question.question_type = #{questionType} </if> <if test="wrongStatus != null "> and t_question_status.wrong_status= #{wrongStatus} </if> <if test="subjectSecondId != null "> and t_question.subject_second_id= #{subjectSecondId} </if> <if test="subjectId != null "> and t_question.subject_id= #{subjectId} </if> </where> </select>
<select id="getUserDingTaskByDdUserIdDeptId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_user_ding_task
where dd_user_id = #{ddUserId} and dept_id = #{deptId} and deleted = 0 limit 1
</select>
還有一種略特殊的
<select id="selectCountByDate" resultType="com.meihui.learning.domain.other.KeyValue"> SELECT create_time as name,COUNT(create_time) as value from ( SELECT DATE_FORMAT(create_time,'%Y-%m-%d') as create_time from t_user_event_log WHERE create_time between #{startTime} and #{endTime} ) a GROUP BY create_time </select>
List<KeyValue> selectCountByDate(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
https://blog.csdn.net/woshixuye/article/details/27521071 這位很詳細