Пример #1
0
  public JasperPrint RelatorioDataProduto(
      java.sql.Timestamp data1, java.sql.Timestamp data2, int idProduto) throws SQLException {
    String path = JPAUtil.getConfRelatorio();
    EntityManager em = new JPAUtil().getEntityManager();
    em.getTransaction().begin();
    Session hibernateSession = em.unwrap(Session.class);

    hibernateSession.doWork(
        new org.hibernate.jdbc.Work() {
          @Override
          public void execute(Connection con) throws SQLException {
            try {
              HashMap map = new HashMap();
              map.put("DataInicio", data1);
              map.put("DataFinal", data2);
              map.put("Produto", idProduto);
              rel = JasperFillManager.fillReport(path + "GeralDatasProduto.jasper", map, con);
              JasperViewer jrviewer = new JasperViewer(rel, false);
              jrviewer.show();
            } catch (JRException ex) {
              Logger.getLogger(RelatorioController.class.getName()).log(Level.SEVERE, null, ex);
            }
          }
        });
    return rel;
  }
Пример #2
0
 public void gerar() throws SQLException {
   String path = JPAUtil.getConfRelatorio();
   System.out.println("End relat: " + path);
   EntityManager em = new JPAUtil().getEntityManager();
   em.getTransaction().begin();
   Session hibernateSession = em.unwrap(Session.class);
   hibernateSession.doWork(
       new org.hibernate.jdbc.Work() {
         @Override
         public void execute(Connection con) throws SQLException {
           try {
             HashMap map = new HashMap();
             JasperPrint rel = JasperFillManager.fillReport(path + "Geral.jasper", map, con);
             JasperViewer jrviewer = new JasperViewer(rel, false);
             jrviewer.show();
           } catch (JRException ex) {
             Logger.getLogger(RelatorioController.class.getName()).log(Level.SEVERE, null, ex);
           }
         }
       });
 }