I’ve a problem with a query that returns multiple value using Spring 3.
I’m using this to retrieve values, but the TemplateFlow objects returned from DB are always null (all field contains null or default value).
List<TemplateFlow> flows = (List<TemplateFlow>) getJdbcTemplate().query(
sqlString,
ParameterizedBeanPropertyRowMapper.newInstance(TemplateFlow.class)
);
TemplateFlow is a class that contains all field. I’m retrieving some values after an update, is it possible I need to commit the changes? (but I’m not using any kind of transaction).
public class TemplateFlow {
private int id_templateflow;
private int id_templateprocess;
public int id_templateflow() { return this.id_templateflow; }
public void id_templateflow(int id_templateflow) { this.id_templateflow = id_templateflow; }
public int id_templateprocess() { return this.id_templateprocess; }
public void id_templateprocess(int id_templateprocess) { this.id_templateprocess = id_templateprocess; }
}
I I try to run the query directly on DB it returns two rows.
thanks for help!
Andrea
Your
TemplateFlowclass does not conform to the javabean pattern, andParameterizedBeanPropertyRowMapperrequires this to be the case:For example, you should have
instead of
However, I’d advise against using
ParameterizedBeanPropertyRowMapperat all – it couples your database too tightly to your code, and that’s not a good thing. Consider instead writing your own implementation ofRowMapper.