记一个mybatis的自定义查询函数的使用方式

272 阅读1分钟

STEP1

在对应的mapper.java

public interface ATMReportsMapper {
    Object selectByExec_id(@Param("execId") String exec_id, @Param("caseId") Long case_id);
}

其中Object为mysql中自定义的数据结构.

STEP2 在对应的表的.xml文件中进行匹配

<mapper>
  <select id="selectByExec_id" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from execute_record
    where exec_id = #{execId,jdbcType=VARCHAR} and case_id = #{caseId,jdbcType=BIGINT}
  </select>
</mapper>