运行以下查询时出现错误。我知道我需要使用'?'与列表大小一样多,但列表大小不同,我不知道如何替换'?'。使用JDBCTemplate执行IN()SQL查询
public List<Object> findAllGrades(String pnr, List<String>codes) {
return jdbcTemplate.query(
"select CourseParticipantship.grade from [thd].[dbo].[CourseParticipantship] "
+ "inner join thd.dbo.CourseMaterial on courseMaterial_id = CourseMaterial.id "
+ "inner join thd.dbo.Course on course_id = Course.id and Course.code in (?)"
+ "inner join thd.dbo.Student on student_id = Student.id "
+ "where Student.personalNumber in (?)",new Object[] { codes, pnr }, new RowMapper() {
public Object mapRow(ResultSet rs, int arg1) throws SQLException {
return rs.getObject("grade");
}
});
}
我得到这个错误:Unable to convert between java.util.ArrayList and JAVA_OBJECT
您应该在这里使用'in':'+“,其中(?)”' – Jens 2015-02-11 10:13:56