Estou com problema ao utilizar Spring e Oracle, quando faço a consulta abaixo, em minha rowmapper, o valor das colunas são
invertidas... por exemplo:
rs.getLong("ID_EMPRESA") = "nome do cliente" //Dá erro por ser getlong...vem com o valor da coluna RAZAO
rs.getString("RAZAO") = null //que seria o valor da coluna ID_EMPRESA
se eu pego pelo index, funciona ....
vejam as classes:
private static final String SQL_FIND_BY_CNPJ = "SELECT NULL \"ID_EMPRESA\", NOME \"RAZAO\" FROM clientes WHERE CNPJ = ?";
public ClientesVO findByPk(Long pkType) {
SpringAddParametersHelper helper = new SpringAddParametersHelper();
helper.add(pkType, Types.NUMERIC);
List<ClientesVO> result = (List<ClientesVO>) jdbcTemplate.query(
helper.getPreparedStatementCreator(SQL_FIND_BY_CNPJ), new ClienteRowMapper());
if (result.isEmpty())
result.add(new ClientesVO());
return result.get(0);
}
rowmapper:
public class ClienteRowMapper implements ParameterizedRowMapper<ClientesVO> {
public ClienteRowMapper() {
}
public ClientesVO mapRow(ResultSet rs, int rowNum) throws SQLException {
ClientesVO result = new ClientesVO();
result.setId(rs.getLong("ID_EMPRESA"));
result.setRazao(rs.getString("RAZAO"));
BeanStringTrimProperties properties = new BeanStringTrimProperties(result);
try {
properties.execute();
} catch (IllegalArgumentException e) {
throw new SQLException(e.getMessage());
} catch (IllegalAccessException e) {
throw new SQLException(e.getMessage());
}
return result;
}
}
uso o mesmo rowmapper quando consulto as mesmas informações em outra base de dados, no caso no SQL Server, e funciona...quando acesso o Oracle dá esse problema.... Alguém sabe porquê isso acontece?
Obrigado.