0

ReportService Code

 private void generatePaySummary() {
        try {
            Map params = new HashMap();
        params = getOrganizationInfo(params);
        params.put("rptsubtitle", "Payroll Date: "+date_formatter.format(tbpaydate.getDate()));

        int i = cboDept.getSelectedIndex();
        int deptno = 0;
        if (i != -1)  deptno = (Integer)deptnos.get(i);

        ReportService srv = new ReportService();
        List empids = srv.getEmployeesInPayroll(deptno, tbpaydate.getDate());
        if (!empids.isEmpty()) {
            PayslipService.setEmployees(empids);
            PayslipService.setPayDate(tbpaydate.getDate());

            RepGenService repsrv = new RepGenService();
            JRBeanCollectionDataSource jbsrc = new JRBeanCollectionDataSource(PaySummaryFactory.getPaySummary());
            repsrv.generateReport(false, "/orgpayroll/reports/jasper/payrollsummary.jasper", true, params, jbsrc);
        }
        else
            SysUtils.messageBox("No employees in payroll on "+date_formatter.format(tbpaydate.getDate())+"!");
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Error" + e.getMessage());
        }
    }

I am trying to execute a function which will open a jasper report template.

The function works if it will only process 1 employee from the database, but if I process more with the same date, it says Hibernate could not initialize proxy - no Session.

1
  • A stack trace of the error would be helpful Commented Sep 27, 2017 at 11:07

1 Answer 1

1

This means that you have one collection with lazy fetchType.

you can solve it by changing it to EAGER mode

So go to ReportService class and turn your employee collection's fetchType to EAGER. Or add (fetch=fetch = FetchType.EAGER)

Sign up to request clarification or add additional context in comments.

3 Comments

The function have too many models. Which specifically model would I show? Thanks for the answer. :)
I mean Payroll and employee !!
Payroll and employee !!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.