2017-09-27 8 views
0

ReportService Codeエラー:Hibernateはプロキシを初期化できませんでした - いいえセッション

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.

+0

エラーのスタックトレースは役に立ちます – ChristopherZ

答えて

1

これは、あなたが怠惰なfetchTypeと1つのコレクションを持っていることを意味します。

you can solve it by changing it to EAGER mode

のでReportServiceクラスに行くとEAGERにあなたの従業員のコレクションのfetchTypeを回します。または追加する(fetch=fetch = FetchType.EAGER)

+0

関数のモデルが多すぎます。私は具体的にどのモデルを見せますか?答えをありがとう。 :) – cleem

+0

ReportServiceと従業員!!! – devuser

+0

私は給与と従業員を意味します! – devuser

関連する問題