mybatis在select查询TIMESTAMP类型的时间时,如果resultType="java.util.HashMap",返回的map中时间的类型仍是TIMESTAMP类型,
想要回显成想要的字符串格式,则用时间函数 DATE_FORMAT(datetime,'%Y-%m-%d %H:%i:%s')
此方法适用于连表查询时 想返回想要的时间串类型
<select id="selectByUserGroupId" parameterType="String" resultType="java.util.HashMap">
SELECT
u.user_id userId,
u.dept_id deptId,
u.user_name userName,
u.user_acc userAcc,
u.user_pwd userPwd,
u.user_salt userSalt,
u.user_state userState,
u.user_company userCompany,
u.user_mobile userMobile,
u.user_email userEmail,
u.user_last_login_time userLastLoginTime,
DATE_FORMAT(u.create_time,'%Y-%m-%d %H:%i:%s') createTime,
u.create_by createBy,
u.update_time updateTime,
u.update_by updateBy,
ud.dept_name deptName,
ur.role_name roleName,
ug.user_group_name userGroupName,
uu.user_ugroup_id userUgroupId
FROM
isomp_user_ugroup uu
INNER JOIN isomp_user_group ug ON ug.user_group_id = uu.user_group_id,
isomp_user u
INNER JOIN isomp_dept ud
ON u.dept_id = ud.dept_id
LEFT JOIN isomp_role ur
ON role_id = (SELECT ru.role_id FROM isomp_role_user ru WHERE ru.user_id = u.user_id)
WHERE uu.user_id = u.user_id AND uu.user_group_id = #{userGroupId,jdbcType=VARCHAR}
</select>
来源:https://www.cnblogs.com/huominglu/p/6723662.html