Spring 3.1.2を使用してWebアプリケーションを開発しており、カスタム行マッパーを作成する必要があります。RowMapperを実装するプライベート静的finalクラスを作成しましたが、「タイプRowMapperはジェネリックではありません。引数でパラメーター化できません」というエラーメッセージが表示されます。
私のlibフォルダー内のすべてのSpring関連のjarは、3.1.2.RELEASEバージョンです。私は他の場所でそのようなものを見つけることができませんでした。なぜこれが起こっているのか考えはありますか?
ありがとう。
サンプルコードは次のとおりです。
public class OutPatient extends Patient{
@Pattern(regexp="[0-9]+", message="OPD No. should only contain digits.")
String opdNo;
public String getOpdNo() {
return opdNo;
}
public void setOpdNo(String opdNo) {
this.opdNo = opdNo;
}
}
DAOクラス:
@Repository("dbHelper")
public class DBHelperImpl{
private JdbcTemplate jdbcTemplate;
private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
@Autowired
public void setDataSource(DataSource dataSource) {
this.jdbcTemplate = new JdbcTemplate(dataSource);
this.namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource);
}
public List<OutPatient> fetchOutPatients() {
String sql = "SELECT OPDNO as opdNo FROM `test`.`out_patient`";
@SuppressWarnings("unchecked") //Have to add this annotation to prevent warning
List<OutPatient> outPatients = jdbcTemplate.query(sql, new OutPatientRowMapper());
return outPatients;
}
private static final class OutPatientRowMapper implements RowMapper{ //Unable to add <OutPatient> generics here!
public OutPatient mapRow(ResultSet rs, int rowNum) throws SQLException {
OutPatient outPatient = new OutPatient();
outPatient.setOpdNo(rs.getString("opdNo"));
return outPatient;
}
}