I have a resultset as a result of a MySQL query using the JDBC connector. So my job is to convert the resultset into a JSON format. So that I can send it to the clientside a
If you utilizing the Spring' JDBCTemplate for executing stored functions which returns cursor as list of the tables entries and, in turns, you wish to map it as a list of the specified bean, then there is the most neat solution:
import com.fasterxml.jackson.databind.ObjectMapper;
...
final static ObjectMapper mapper = new ObjectMapper();
...
List populateExecuteRetrieve(SimpleJdbcCall call, Map inputParameters, Class outputClass) {
List> sqlResult;
sqlResult = call.executeFunction(ArrayList.class, parameter);
return sqlResult
.stream()
.map(entry -> mapper.convertValue(entry, outputBeanClass))
.collect(Collectors.toList());
}
You are welcome!
Happy coding!