1

Spring.NET の「SimpleJdbcCall」、「MapSqlParameterSource」、および「BeanPropertySqlParameterSource」に相当するものは何ですか? Spring.NET で以下の Java を記述する方法:

publicvoid create(T object) {
if(object==null)
return null;
SimpleJdbcCall pspCreate = new SimpleJdbcCall(jdbcTemplate).withProcedureName("cr eate_sp").withReturnValue().declareParameters(new SqlOutParameter("id", Types.BIGINT));
SqlParameterSource in = new BeanPropertySqlParameterSource(object);
Map<String, Object> m = pspCreate.execute(in);
long id = m.containsKey(IDENTITY_VALUE)?(Long) m.get(IDENTITY_VALUE):0;
int resultCode =m.containsKey(RETURN_VALUE)?(Integer) m.get(RETURN_VALUE):0;
}


public List<T> retrieveAll(int pageNum, int pageSize) {
SqlParameterSource in = new MapSqlParameterSource()
.addValue("pageNum", pageNum, Types.INTEGER)
.addValue("pageSize", pageSize, Types.INTEGER);

SimpleJdbcCall pspRetrieveAll =new SimpleJdbcCall(jdbcTemplate).withProcedureName("re trieve_all_sp").withReturnValue().returningResultS et("LIST", BeanPropertyRowMapper.newInstance(UploadBatch.clas s)).returningResultSet(NO_OF_RECORDS, new RowMapper<Long>() {

@Override
public Long mapRow(ResultSet rs, int rowNum) throws SQLException {
return rs.getLong(1);
}
});
Map<String, Object> m = pspRetrieveAll.execute(in);
List<T> list=null;
if(m.containsKey(LIST))
list = (List<T>) m.get(LIST);

return list;
} 
4

1 に答える 1

0

ADO.NET の章を使用してデータ アクセスを確認します。

http://www.springframework.net/doc-latest/reference/html/ado.html

于 2012-11-06T09:25:50.347 に答える