1
Doubt in the use of Jasperprint without a Collection
The following code should generate a PDF using only one Ready DTO object, but the problem is that the Jrbeancollectiondatasource instance:
Jasperprint jasperPrint = Jasperfillmanager.fillReport(inputStream, parameters, new Jrbeancollectiondatasource(data));
does not accept only one object and I cannot find a way to use without a Collection.
I have the following code:
public byte[] relatorioPorPaciente(Long codigo) throws Exception {
ProntuarioRelatorioID dados = this.agendamentoRepository.porPaciente(codigo);
Map<String, Object> parametros = new HashMap<String, Object>();
parametros.put("ID", Long.valueOf(codigo));
parametros.put("REPORT_LOCALE", new Locale("pt", "BR"));
InputStream inputStream = this.getClass().getResourceAsStream("/relatorios/relatorio_prontuario.jasper");
JasperPrint jasperPrint = JasperFillManager.fillReport(inputStream, parametros,new JRBeanCollectionDataSource(dados));
return JasperExportManager.exportReportToPdf(jasperPrint);
}