errors in query operations using annotations and SQLProvider
it is OK to use annotations directly, but not with SQLProvider.
//
@Select({
"<script>"
+ "SELECT avator FROM t_user "
+ "WHERE id IN "
+ "<foreach item="item" collection="list" open="(" separator="," close=")">"
+ "-sharp{item}"
+ "</foreach>"
+ "</script>"
})
List<String> getAvator(List<Integer> userIds);
tried neither of the following
//
@SelectProvider(type = UserSql.class, method = "getAvator2")
List<String> getAvator2(@Param("list")List<Integer> userIds);
@SelectProvider(type = UserSql.class, method = "getAvator3")
List<String> getAvator3(String userIds); // 4,5,6,7
// SQL
public String getAvator2(List<Integer> userIds) {
StringBuilder sql = new StringBuilder()
.append("SELECT avator FROM ")
.append(TABLE_NAME)
.append(" <foreach item="item" collection="list" open="(" separator="," close=")">")
.append(" -sharp{item}")
.append(" </foreach>");
return sql.toString();
}
public String getAvator3(String userIds) {
StringBuilder sql = new StringBuilder()
.append("SELECT avator FROM ")
.append(TABLE_NAME)
.append(" WHERE id IN (-sharp{userIds})");
return sql.toString();
}