0
我正在学习在java中使用存储过程。早些时候,我使用JDBC模板,我能够从数据库中获取值。 现在我有一个错误:收集对象不能转换为列表类错误 - 收集<Object>不能转换为列表<Class>
有没有什么办法可以将Collection(Object)转换为List(Class)?
是我的模型类
我的存储过程类
public class ListRegistration extends StoredProcedure {
@Autowired
private DataSource dataSource;
private static final String SCHEMA_NAME = "ehr";
private static final String SPROC_NAME = "ehr.usp_ListRegistration";
public DataSource getDataSource() {
return dataSource;
}
public ListRegistration(DataSource dataSource) {
super(dataSource, SPROC_NAME);
declareParameter(new SqlReturnResultSet("rs", new BeanPropertyRowMapper(Patient.class)));
declareParameter(new SqlParameter("LimitRows", Types.INTEGER));
compile();
}
public List<Patient> spExecute(Integer LimitRows)
{
Map<String, Object> registrationResult=new HashMap<String,Object>();
registrationResult = super.execute(LimitRows);
List<Patient> patientList = new ArrayList<Patient>;
patientList = registrationResult.values();
return patientList;
}
}
List<Patient> patientList = new ArrayList<Patient>;
patientList = registrationResult.values();
这是我的错误。
在我implementaion类我有
public List<Patient> getPatient() {
System.out.println("============================ Will Fetch Values ");
List<Patient> patientList = new ArrayList<Patient>();
int t=100;
patientList=listRegistration.spExecute(100);
return patientList;
}
可否请您发布您的StoredProcedure类 –
我已经给出了上面的存储过程类。 –