小编Mig*_*hty的帖子

Spring 3.1.2 RowMapper参数化

我正在使用Spring 3.1.2开发Web应用程序,并且需要创建自定义行映射器。我创建了一个私有静态最终类,该类实现了RowMapper,但是我收到错误消息“ 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;
}
}
Run Code Online (Sandbox Code Playgroud)

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 …
Run Code Online (Sandbox Code Playgroud)

java generics spring spring-mvc spring-3

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

generics ×1

java ×1

spring ×1

spring-3 ×1

spring-mvc ×1