Example usage for org.hibernate.internal SessionImpl connection

List of usage examples for org.hibernate.internal SessionImpl connection

Introduction

In this page you can find the example usage for org.hibernate.internal SessionImpl connection.

Prototype

@Override
    public Connection connection() throws HibernateException 

Source Link

Usage

From source file:at.stefanproell.ResultSetVerification.ResultSetHashAlternatives.java

License:Apache License

/**
 * Get the connection from the connection pool
 *
 * @return//from  w ww.j  av a 2  s  .c  o  m
 */
private Connection getConnection() {
    Connection connection = null;
    Session session = HibernateUtilData.getSessionFactory().openSession();
    SessionImpl sessionImpl = (SessionImpl) session;
    connection = sessionImpl.connection();
    return connection;

}

From source file:br.com.alberteije.balcao.DavController.java

License:Open Source License

public void imprimeDav() {
    EcfDavCabecalhoVO davCabecalho = (EcfDavCabecalhoVO) this.grid.getForm1().getVOModel().getValueObject();
    try {//  w  w  w . ja v a  2 s .  com
        Session session = HibernateUtil.getSessionFactory().openSession();
        EcfEmpresaVO empresa = (EcfEmpresaVO) session.load(EcfEmpresaVO.class, 1);

        HashMap parametros = new HashMap();
        parametros.put("NOME_EMPRESA", empresa.getRazaoSocial());
        parametros.put("CNPJ_EMPRESA", empresa.getCnpj());
        parametros.put("CODIGO_DAV", davCabecalho.getId());

        SessionImpl sessionImpl = (SessionImpl) session;
        Connection connection = sessionImpl.connection();
        JasperPrint jp = JasperFillManager.fillReport("./relatorios/DAV.jasper", parametros, connection);
        JasperPrintManager.printPage(jp, 0, false);

        //JasperViewer jv = new JasperViewer(jp);
        //jv.viewReport(jp, false);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.court.controller.CollectionSheetFxmlController.java

private void generateCollectionPaymentReport(String chkNo) {
    // String reportPath = "com/court/reports/BranchWiseCollectionMadeReport.jasper";

    String reportPath = null;//from ww  w. ja v a 2 s . c o  m
    try {
        reportPath = PropHandler.getStringProperty("report_path") + "BranchWiseCollectionMadeReport.jasper";
    } catch (IOException ex) {
        Logger.getLogger(CollectionSheetFxmlController.class.getName()).log(Level.SEVERE, null, ex);
    }

    Session s = HibernateUtil.getSessionFactory().openSession();
    SessionImpl smpl = (SessionImpl) s;
    Connection con = smpl.connection();
    Map<String, Object> map = new HashMap<>();
    map.put("companyName", ReportHandler.COMPANY_NAME);
    map.put("companyAddress", ReportHandler.ADDRESS);
    map.put("reportTitle", "Branch Wise Cheque Payments");
    map.put("chk_no", chkNo);
    ReportHandler rh = new ReportHandler(reportPath, map, null, con);
    boolean blah = rh.genReport();
    if (blah) {
        rh.viewReport();
    }
    s.close();
}

From source file:com.court.controller.MemberfxmlController.java

@FXML
private void onGenerateSubsInvoAction(ActionEvent event) {
    Session s = HibernateUtil.getSessionFactory().openSession();
    s.beginTransaction();//from   www .  j av  a 2s  . c om
    ReceiptPay rp = new ReceiptPay();
    // rp.setReceiptCode("INV" + FxUtilsHandler.generateRandomNumber(7));
    rp.setPaymentType("subscription");
    rp.setPayDate(new java.util.Date());
    rp.setPayIds(new Gson().toJson(subIds, new TypeToken<List<Integer>>() {
    }.getType()));
    rp.setAmount(amt_totsub);
    rp.setMember(getMemberByCode(member_code_txt.getText(), s));
    s.save(rp);
    s.getTransaction().commit();

    // String reportPath = "com/court/reports/SubscriptionPayInvoiceReport.jasper";
    String reportPath = null;
    try {
        reportPath = PropHandler.getStringProperty("report_path") + "SubscriptionPayInvoiceReport.jasper";
    } catch (IOException ex) {
        Logger.getLogger(MemberfxmlController.class.getName()).log(Level.SEVERE, null, ex);
    }

    SessionImpl smpl = (SessionImpl) s;
    Connection con = smpl.connection();
    Map<String, Object> map = new HashMap<>();
    map.put("companyName", ReportHandler.COMPANY_NAME);
    map.put("companyAddress", ReportHandler.ADDRESS);
    map.put("reportTitle", "Subscription Pay Invoice");
    map.put("member_code", member_code_txt.getText());
    map.put("sp_list", subIds.stream().map(i -> String.valueOf(i.intValue())).collect(Collectors.joining(",")));
    ReportHandler rh = new ReportHandler(reportPath, map, null, con);
    boolean blah = rh.genReport();
    if (blah) {
        rh.viewReport();
    }
    s.close();
    //==================//RESET ALL FREEZED NODES========================
    freezeAtMemberContribution(false);
    invo_gen_box.setVisible(false);
    initContributionTable(FXCollections.observableArrayList(getAllContributionsOf(member_code_txt.getText())));
}

From source file:com.court.controller.MemberfxmlController.java

private void genaratePaymentReport(List<Integer> lpIds, String mCode, String reportTitle) {
    // String reportPath = "com/court/reports/InstallmentPayInvoiceReport.jasper";

    String reportPath = null;/*from w  w w  .ja  v a2  s.c o  m*/
    try {
        reportPath = PropHandler.getStringProperty("report_path") + "InstallmentPayInvoiceReport.jasper";
    } catch (IOException ex) {
        Logger.getLogger(MemberfxmlController.class.getName()).log(Level.SEVERE, null, ex);
    }

    Session s = HibernateUtil.getSessionFactory().openSession();
    SessionImpl smpl = (SessionImpl) s;
    Connection con = smpl.connection();
    Map<String, Object> map = new HashMap<>();
    map.put("companyName", ReportHandler.COMPANY_NAME);
    map.put("companyAddress", ReportHandler.ADDRESS);
    map.put("reportTitle", reportTitle);
    map.put("member_code", mCode);
    map.put("lp_list", lpIds.stream().map(i -> String.valueOf(i.intValue())).collect(Collectors.joining(",")));
    ReportHandler rh = new ReportHandler(reportPath, map, null, con);
    boolean blah = rh.genReport();
    if (blah) {
        rh.viewReport();
    }
    s.close();
}

From source file:com.court.controller.MemberfxmlController.java

private boolean generateArrearsRecoverReport(List<Integer> codes, double arrears, String memberId,
        String fullName, Session s) {
    boolean b = false;

    String reportPath = null;/*from  w w w .j av  a 2 s .c  om*/
    try {
        reportPath = PropHandler.getStringProperty("report_path") + "SettleArrearsWithOverpayReport.jasper";
        SessionImpl smpl = (SessionImpl) s;
        Connection con = smpl.connection();
        Map<String, Object> map = new HashMap<>();
        map.put("companyName", ReportHandler.COMPANY_NAME);
        map.put("companyAddress", ReportHandler.ADDRESS);
        map.put("reportTitle", "Arrears Settlement Report ");
        map.put("ml_ids", codes);
        map.put("settleTot", arrears);
        map.put("mbrCode", memberId);
        map.put("mbrName", fullName);
        ReportHandler rh = new ReportHandler(reportPath, map, null, con);

        b = rh.genReport();
        if (b) {
            rh.viewReport();
        }

    } catch (IOException ex) {
        Logger.getLogger(MemberfxmlController.class.getName()).log(Level.SEVERE, null, ex);
    }
    return b;
}

From source file:com.court.controller.MemberfxmlController.java

private void generateOverpayHandoverReport(String memberId, String fullName, double handover, Session s) {

    String reportPath = null;/* w w w. j  a  va 2s  . c o m*/
    try {
        reportPath = PropHandler.getStringProperty("report_path") + "OverpayHandoverReport.jasper";
        SessionImpl smpl = (SessionImpl) s;
        Connection con = smpl.connection();
        Map<String, Object> map = new HashMap<>();
        map.put("companyName", ReportHandler.COMPANY_NAME);
        map.put("companyAddress", ReportHandler.ADDRESS);
        map.put("reportTitle", "Overpay Customer Handover Report ");
        map.put("handoverTot", handover);
        map.put("mbrCode", memberId);
        map.put("mbrName", fullName);
        ReportHandler rh = new ReportHandler(reportPath, map, null, con);

        boolean b = rh.genReport();
        if (b) {
            rh.viewReport();
        }

    } catch (IOException ex) {
        Logger.getLogger(MemberfxmlController.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.court.controller.ReportFormFxmlController.java

@FXML
private void onBranchCollectionDueAction(ActionEvent event) throws JRException {

    Dialog<BrColDue> dialog = new Dialog<>();
    dialog.setTitle("Branch wise Collection Due");
    dialog.setHeaderText("Select Payment Office");
    ButtonType viewBtn = new ButtonType("View Report", ButtonData.OK_DONE);
    dialog.getDialogPane().getButtonTypes().addAll(viewBtn, ButtonType.CANCEL);
    GridPane grid = new GridPane();
    grid.setHgap(10);//from  www  .j ava  2s.  co m
    grid.setVgap(10);
    grid.setPadding(new Insets(20, 150, 10, 10));

    TextField bField = new TextField();
    ComboBox<String> cbox = new ComboBox<>(FXCollections.observableArrayList("Permanent", "Casual"));
    ComboBox<String> jcbox = new ComboBox<>(
            FXCollections.observableArrayList("With Judges", "Without Judges", "Only Judges"));
    cbox.getSelectionModel().selectFirst();
    jcbox.getSelectionModel().select(1);
    TextFields.bindAutoCompletion(bField, getPaymentOffice());

    grid.add(new Label("Branch:"), 0, 0);
    grid.add(bField, 1, 0);
    grid.add(new Label("Job Status:"), 0, 1);
    grid.add(cbox, 1, 1);
    grid.add(new Label("Report:"), 0, 2);
    grid.add(jcbox, 1, 2);
    dialog.getDialogPane().setContent(grid);
    dialog.setResultConverter(db -> {
        if (db == viewBtn) {
            if (bField.getText().isEmpty()) {
                return null;
            } else {
                return new BrColDue(getPayOfficeIdFromCode(bField.getText().split("-")[0]),
                        cbox.getSelectionModel().getSelectedItem(),
                        jcbox.getSelectionModel().getSelectedIndex());
            }
        }
        return null;
    });

    Optional<BrColDue> result = dialog.showAndWait();
    result.ifPresent(b -> {
        //String reportPath = "com/court/reports/BranchWiseCollection.jasper";

        String reportPath = null;
        try {
            reportPath = PropHandler.getStringProperty("report_path") + "BranchWiseCollection.jasper";
        } catch (IOException ex) {
            Logger.getLogger(ReportFormFxmlController.class.getName()).log(Level.SEVERE, null, ex);
        }

        Session s = HibernateUtil.getSessionFactory().openSession();
        SessionImpl smpl = (SessionImpl) s;
        Connection con = smpl.connection();
        Map<String, Object> map = new HashMap<>();
        map.put("companyName", ReportHandler.COMPANY_NAME);
        map.put("companyAddress", ReportHandler.ADDRESS);
        map.put("reportTitle", "Branch Wise Collection");
        map.put("p_brcode", Integer.parseInt(b.getBranch()));
        map.put("job_stat", b.getJobStat());
        map.put("judges", b.getJudges());
        System.out.println("JOB - " + b.getJobStat());
        ReportHandler rh = new ReportHandler(reportPath, map, null, con);
        //            rh.genarateReport();
        boolean blah = rh.genReport();
        if (blah) {
            rh.viewReport();
        }
        s.close();
    });
}

From source file:com.court.controller.ReportFormFxmlController.java

@FXML
private void onBranchCollectionMadeAction(ActionEvent event) {

    Dialog<String> dialog = new Dialog<>();
    dialog.setTitle("Branch Wise Cheque Payments");
    dialog.setHeaderText("Select Cheque and Branch ");
    ButtonType viewBtn = new ButtonType("View Report", ButtonData.OK_DONE);
    dialog.getDialogPane().getButtonTypes().addAll(viewBtn, ButtonType.CANCEL);
    GridPane grid = new GridPane();
    grid.setHgap(10);/*w  ww .j  a v a 2 s . com*/
    grid.setVgap(10);
    grid.setPadding(new Insets(20, 150, 10, 10));

    TextField cField = new TextField();
    TextFields.bindAutoCompletion(cField, getCollectionInvoice());

    grid.add(new Label("Invoice:"), 0, 1);
    grid.add(cField, 1, 1);

    dialog.getDialogPane().setContent(grid);
    dialog.setResultConverter(db -> {
        if (db == viewBtn) {
            return cField.getText();
        }
        return null;
    });

    Optional<String> result = dialog.showAndWait();
    result.ifPresent(invo -> {
        if ((invo != null && !invo.isEmpty())) {
            // String reportPath = "com/court/reports/BranchWisePaymentMadeReport.jasper";

            String reportPath = null;
            try {
                reportPath = PropHandler.getStringProperty("report_path")
                        + "BranchWisePaymentMadeReport.jasper";
            } catch (IOException ex) {
                Logger.getLogger(ReportFormFxmlController.class.getName()).log(Level.SEVERE, null, ex);
            }

            Session s = HibernateUtil.getSessionFactory().openSession();
            SessionImpl smpl = (SessionImpl) s;
            Connection con = smpl.connection();
            Map<String, Object> map = new HashMap<>();
            map.put("companyName", ReportHandler.COMPANY_NAME);
            map.put("companyAddress", ReportHandler.ADDRESS);
            map.put("reportTitle", "Office Wise Cheque Payments");
            map.put("invo_code", invo);
            ReportHandler rh = new ReportHandler(reportPath, map, null, con);
            //                rh.genarateReport();
            boolean blah = rh.genReport();
            if (blah) {
                rh.viewReport();
            }
            s.close();
        } else {
            Alert alert_error = new Alert(Alert.AlertType.ERROR);
            alert_error.setTitle("Error");
            alert_error.setHeaderText("Empty fields found ! ");
            alert_error.setContentText("You have to enter both Cheque and Office correctly to get the report.");
            alert_error.show();
        }
    });

}

From source file:com.court.controller.ReportFormFxmlController.java

@FXML

private void onBranchAction(ActionEvent event) throws JRException {
    //  String reportPath = "com/court/reports/BranchReport.jasper";
    // String subReportPath = "com/court/reports/BranchSubReport.jasper";

    String reportPath = null, subReportPath = null;
    try {//from w w  w  .  j av a  2  s . c o  m
        reportPath = PropHandler.getStringProperty("report_path") + "BranchReport.jasper";
        subReportPath = PropHandler.getStringProperty("report_path") + "BranchSubReport.jasper";
    } catch (IOException ex) {
        Logger.getLogger(ReportFormFxmlController.class.getName()).log(Level.SEVERE, null, ex);
    }

    Session s = HibernateUtil.getSessionFactory().openSession();
    SessionImpl smpl = (SessionImpl) s;
    Connection con = smpl.connection();
    Criteria c = s.createCriteria(Branch.class, "b");
    c.add(Restrictions.eq("b.status", true));
    c.add(Restrictions.eq("b.parentId", 0));
    List<Branch> list = c.list();

    JasperReport subReport = (JasperReport) JRLoader.loadObject(new File(subReportPath));

    JRBeanCollectionDataSource memberLoanBeanCollection = new JRBeanCollectionDataSource(list);
    Map<String, Object> map = new HashMap<>();
    map.put("companyName", ReportHandler.COMPANY_NAME);
    map.put("companyAddress", ReportHandler.ADDRESS);
    map.put("report_dbcon", con);
    map.put("reportTitle", "Court List");
    map.put("SUBREPORT", subReport);
    ReportHandler rh = new ReportHandler(reportPath, map, memberLoanBeanCollection);
    //        rh.genarateReport();
    boolean blah = rh.genReport();
    if (blah) {
        rh.viewReport();
    }
    s.close();
}