我在使用Mybatis注释的IN子句的Code Snippet下面使用。我没有在执行时获得任何异常,但它返回0行。
请帮帮我。
@Select("SELECT A.* FROM RPRT_HDR A,SCHL_MSTR B WHERE A.SCHL_ID=B.SCHL_ID AND B.SCHOOL_NAME in (#{schools}) AND A.YR_MTH=#{ym}")
@Results(value={
@Result(property ="rprtKey",column="RPRT_KEY"),
@Result(property="reportImage",javaType = List.class,column ="rprtKey",many=@Many(select="getImages")),
@Result(property="reportQnAns",javaType = List.class,column ="rprtKey",many=@Many(select="getQuestionAnswer"))
})
List<ReportHeader> getReportdata(@Param("schools")String[] schools,@Param("ym")int yearmonth );
答案 0 :(得分:0)
查询有效,因为Mybatis实际上将String数组发送到String,然后是有效的,但是只有匹配字符串的记录。
写:@Select("<script>SELECT A.* FROM RPRT_HDR A,SCHL_MSTR B WHERE A.SCHL_ID=B.SCHL_ID AND B.SCHOOL_NAME in (<foreach collection='schools' item='school' separator=', '>#{school}</foreach>) AND A.YR_MTH=#{ym}</script>")