mercredi 27 août 2014

SimpleJdbcCall returning one empty bean if ResultSet is empty


Vote count:

0




I'm having a weird behavior when calling a MySQL Stored Procedure that returns a single resultset using SimpleJdbcCall (Spring).


When the Stored Procedure returns one or more rows in the resultset, the list have the expected elements. The problem is when the resultset is empty, because the list have one element with all its attributes in null, instead of an empty list.


This behavior occurs when running the application on Tomcat. When I run a JUnit test on Eclipse, everything works fine.



...

SimpleJdbcCall call = new SimpleJdbcCall(dataSource);

call.setProcedureName(procedureName);

if (parameters != null) {
for (SqlParameter parameter : parameters) {
call.addDeclaredParameter(parameter);
}
}

if (rowMappers != null) {
int index = 1;
for (RowMapper<?> rowMapper : rowMappers) {
call.addDeclaredRowMapper("rs" + index, rowMapper);
index++;
}
}

...

Map<String, Object> output = call.execute(args);

List<Bean> beans = (List<Bean>) output.get("rs1");

//beans have one item with all attributes in null when resultset is empty


asked 15 secs ago







SimpleJdbcCall returning one empty bean if ResultSet is empty

Aucun commentaire:

Enregistrer un commentaire