Fórum Erro java.lang.NullPointerException (RESOLVIDO) #567478
02/09/2011
0
String hql = "SELECT f.sigla, f.nome, f.tipo, f.n_apropriacao, f.local, f.centroCusto, f.descricaoCC, h.hora, h.dt_Dia as data, h.destino as registro ";
hql += "FROM Funcionario f, Horario h ";
hql += "WHERE to_date(h.dt_Dia, 'dd/MM/yyyy') BETWEEN :dataInicio AND :dataFinal ";
hql += "AND to_timestamp(h.hora, 'HH24:MI') > to_timestamp('09:00', 'HH24:MI') ";
hql += "AND to_timestamp(h.hora, 'HH24:MI') < to_timestamp('17:00', 'HH24:MI') ";
hql += "AND flag_destino <> 'atestado'";
Gabriela Oliveira
Curtir tópico
+ 0Post mais votado
02/09/2011
Douglas Eric
Gostei + 1
Mais Posts
02/09/2011
Douglas Eric
Erro ao gerar o relatorio. java.lang.NullPointerException
java.lang.NullPointerException
acompanhamento.relatorios.RelatorioHorasFuncPeriodo.gerarRelatorio(RelatorioHorasFuncPeriodo.java:42)
public class RelatorioHorasFuncPeriodo {
private Date dataInicio;
private Date dataFinal;
public void gerarRelatorio() {
HashMap parametros = new HashMap();
JRBeanCollectionDataSource beanRelatorios;
JasperPrint impressao;
String caminhoJasper, caminhoRelatorio;
HorasFuncionarioPeriodoDao dao = new HorasFuncionarioPeriodoDao();
try {
caminhoJasper = "D:\\Projetos\\Acompanhamento\\web\\relatorios\\jasper\\relHorasFuncPer.jasper";
caminhoRelatorio = "D:\\Projetos\\Acompanhamento\\web\\relatorios\\relHorasFuncPer.xls";
parametros.put("dataInicio", dataInicio);
parametros.put("dataFinal", dataFinal);
beanRelatorios = new JRBeanCollectionDataSource(dao.gethorasFuncionarioPeriodo(dataInicio, dataFinal));
(42) impressao = JasperFillManager.fillReport(caminhoJasper, parametros, beanRelatorios);
//Gerando Xls
JRXlsExporter xls = new JRXlsExporter();
xls.setParameter(JRExporterParameter.JASPER_PRINT, impressao);
xls.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, caminhoRelatorio);
xls.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, false);
xls.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, true);
xls.setParameter(JRXlsExporterParameter.IS_DETECT_CELL_TYPE, true);
xls.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, false);
xls.exportReport();
} catch (Exception e) {
System.out.println("Erro ao gerar o relatorio. " + e);
e.printStackTrace();
}
}Gostei + 0
02/09/2011
Douglas Eric
public class HorasFuncionarioPeriodoDao {
public List horasFuncionarioPeriodo(Date dataIni, Date dataFim) {
List<HorasFuncionarioPeriodo> listaFunc = new ArrayList<HorasFuncionarioPeriodo>();
SimpleDateFormat sf = new SimpleDateFormat();
HorasFuncionarioPeriodo hrFuncPer;
Session session = HibernateUtil.getSession();
String hql = "SELECT f.sigla, f.nome, f.tipo, f.n_apropriacao, f.local, f.centroCusto, f.descricaoCC, h.hora, h.dtDia as data, h.destino as registro ";
hql += "FROM funcionario f, Horario h ";
// hql += " WHERE to_date(h.dtDia,'DD/MM/YYYY') BETWEEN :dataIni AND :dataFim ";
// hql += " AND to_timestamp(h.hora, 'HH24:MI') > to_timestamp('09:00', 'HH24:MI') ";
// hql += " AND to_timestamp(h.hora, 'HH24:MI') < to_timestamp('17:00', 'HH24:MI') ";
// hql += " AND flag_destino <> 'atestado' ";
hql += " WHERE h.pessoa = LOWER(f.sigla) ";
hql += " WHERE h.hora IS NOT NULL ";
try {
session.beginTransaction();
Query query = session.createQuery(hql);
query.setDate("dataIni", dataIni);
query.setDate("dataFim", dataFim);
for (Iterator it = query.iterate(); it.hasNext();) {
Object[] registro = (Object[]) it.next();
hrFuncPer = new HorasFuncionarioPeriodo();
hrFuncPer.setSigla(registro[0].toString());
hrFuncPer.setNome(registro[1].toString());
hrFuncPer.setTipo(registro[2].toString());
hrFuncPer.setN_Apropriacao(Integer.parseInt(registro[3].toString()));
hrFuncPer.setLocal(registro[4].toString());
hrFuncPer.setCentroCusto(registro[5].toString());
hrFuncPer.setDescricaoCC(registro[6].toString());
hrFuncPer.setHora(registro[7].toString());
hrFuncPer.setDtDia((Date)registro[8]);
hrFuncPer.setDestino(registro[9].toString());
listaFunc.add(hrFuncPer);
}
session.beginTransaction().commit();
} catch (Exception e) {
e.printStackTrace();
} finally {
session.close();
}
return listaFunc;
}
}
Gostei + 0
02/09/2011
Douglas Eric
Erro ao gerar o relatorio. java.lang.NullPointerException java.lang.NullPointerException acompanhamento.relatorios.RelatorioHorasFuncPeriodo.gerarRelatorio(RelatorioHorasFuncPeriodo.java:42)