其他同学提供的方式大部分都是Map接收调用mysql存储过程返回OUT结果集,要么游标,要么单个OUT,然后再次加工成想要的对象。涉及到直接用注解实现自动转换OUT参数结果集为对象时,都是忽略带过。
下面为各位踩坑的同学上代码描述如何处理调用mysql多in多out的存储过程:
@Options(statementType = StatementType.CALLABLE)
@Select("CALL jira_gf.Proc_YFZX_GetProjectIssuesByProjectKeyAndVersionAndIssueType_dev(" +
"#{projectKey,mode=IN,jdbcType=VARCHAR}," +
"#{fixOrAffectversion,mode=IN,jdbcType=VARCHAR}," +
"#{issueType,mode=IN,jdbcType=VARCHAR}," +
"#{project_id,mode=OUT,jdbcType= INTEGER}," +
"#{project_name,mode=OUT, jdbcType=VARCHAR}," +
"#{project_key,mode=OUT, jdbcType=VARCHAR}," +
"#{version_id,mode=OUT,jdbcType=INTEGER}," +
"#{version_name,mode=OUT,jdbcType=VARCHAR}," +
"#{version_startdate,mode=OUT,jdbcType=VARCHAR}," +
"#{version_releasedate,mode=OUT,jdbcType=VARCHAR}," +
"#{version_archived,mode=OUT,jdbcType=VARCHAR}," +
"#{version_released,mode=OUT,jdbcType=VARCHAR}," +
"#{sprint_id,mode=OUT,jdbcType=INTEGER}," +
"#{sprint_name,mode=OUT,jdbcType=VARCHAR}," +
"#{sprint_startdate,mode=OUT,jdbcType=BIGINT}," +
"#{sprint_startdate_datetime,mode=OUT,jdbcType=VARCHAR}," +
"#{sprint_enddate,mode=OUT,jdbcType=BIGINT}," +
"#{sprint_enddate_datetime,mode=OUT,jdbcType=VARCHAR}," +
"#{sprint_completedat,mode=OUT,jdbcType=BIGINT}," +
"#{sprint_completedate_datetime,mode=OUT,jdbcType=VARCHAR}," +
"#{sprint_started,mode=OUT,jdbcType=INTEGER}," +
"#{sprint_closed,mode=OUT,jdbcType=INTEGER}," +
"#{issue_id,mode=OUT,jdbcType=INTEGER}," +
"#{issue_status,mode=OUT,jdbcType=INTEGER}," +
"#{status_name,mode=OUT,jdbcType=VARCHAR}," +
"#{issuetotal,mode=OUT,jdbcType=INTEGER})")
@Results(value = {
@Result(property = "projectId", column = "project_id"),
@Result(property = "projectName", column = "project_name"),
@Result(property = "projectKey", column = "project_key"),
@Result(property = "versionId", column = "version_id"),
@Result(property = "versionName", column = "version_name"),
@Result(property = "versionStartdate", column = "version_startdate"),
@Result(property = "versionReleasedate", column = "version_releasedate"),
@Result(property = "versionArchived", column = "version_archived"),
@Result(property = "versionReleased", column = "version_released"),
@Result(property = "sprintId", column = "sprint_id"),
@Result(property = "sprintName", column = "sprint_name"),
@Result(property = "sprintStartdate", column = "sprint_startdate"),
@Result(property = "sprintStartdateDatetime", column = "sprint_startdate_datetime"),
@Result(property = "sprintEnddate", column = "sprint_enddate"),
@Result(property = "sprintEnddateDatetime", column = "sprint_enddate_datetime"),
@Result(property = "sprintCompletedate", column = "sprint_completedate"),
@Result(property = "sprintCompletedateDatetime", column = "sprint_completedate_datetime"),
@Result(property = "sprintStarted", column = "sprint_started"),
@Result(property = "sprintClosed", column = "sprint_closed"),
@Result(property = "issueId", column = "issue_id"),
@Result(property = "issueStatus", column = "issue_status"),
@Result(property = "statusName", column = "status_name"),
@Result(property = "issueTotal", column = "issuetotal")
})
List getTargetProjectWithIssuesByPorjectKeyAndVersionAndIssueType(@Param("projectKey") String projectKey, @Param("fixOrAffectversion") String fixOrAffectversion, @Param("issueType") String issueType);