Example usage for org.hibernate Session flush

List of usage examples for org.hibernate Session flush

Introduction

In this page you can find the example usage for org.hibernate Session flush.

Prototype

void flush() throws HibernateException;

Source Link

Document

Force this session to flush.

Usage

From source file:autoancillarieslimited.hiberate.dao.EmployeeDAO.java

public List<Employee> getEmployees() {
    List<Employee> set = null;
    Session session = null;
    Transaction beginTransaction = null;
    try {/*  w  w  w.  j av  a 2  s  . c o m*/
        session = HibernateUtil.getSessionFactory().openSession();
        beginTransaction = session.beginTransaction();
        set = session.createQuery("from Employee").list();
        session.flush();
        session.clear();
        session.getTransaction().commit();
    } catch (HibernateException ex) {
        ex.printStackTrace();
        if (beginTransaction != null) {
            beginTransaction.rollback();
        }
    } finally {
        if (session != null) {
            session.close();
        }
    }
    return set;
}

From source file:autoancillarieslimited.hiberate.dao.EmployeeDAO.java

public Employee checkLogin(String email, String password) {
    Employee item = null;//from w w  w .  j av  a2  s  .  c  o  m
    Session session = null;
    Transaction beginTransaction = null;
    try {
        session = HibernateUtil.getSessionFactory().openSession();
        beginTransaction = session.beginTransaction();
        item = (Employee) session
                .createQuery(
                        "from Employee where Email like '" + email + "' AND Password like '" + password + "'")
                .uniqueResult();
        session.flush();
        session.clear();
        beginTransaction.commit();
    } catch (HibernateException ex) {
        ex.printStackTrace();
        if (beginTransaction != null) {
            beginTransaction.rollback();
        }
    } finally {
        if (session != null) {
            session.close();
        }
    }
    return item;
}

From source file:autoancillarieslimited.hiberate.dao.EmployeeDAO.java

public Admin checkLoginAdmin(String email, String password) {
    Admin item = null;// w  ww .  j a v  a  2 s .  com
    Session session = null;
    Transaction beginTransaction = null;
    try {
        session = HibernateUtil.getSessionFactory().openSession();
        beginTransaction = session.beginTransaction();
        item = (Admin) session
                .createQuery("from Admin where Email like '" + email + "' AND PassWord like '" + password + "'")
                .uniqueResult();
        session.flush();
        session.clear();
        beginTransaction.commit();
    } catch (HibernateException ex) {
        ex.printStackTrace();
        if (beginTransaction != null) {
            beginTransaction.rollback();
        }
    } finally {
        if (session != null) {
            session.close();
        }
    }
    return item;
}

From source file:autoancillarieslimited.hiberate.dao.OrderDAO.java

public List<ItemOrder> getItemOrderByIDPurchase(int id) {
    List<ItemOrder> list = new ArrayList<>();
    Session session = null;
    Transaction beginTransaction = null;
    try {//ww  w.j  ava2  s.  com
        session = HibernateUtil.getSessionFactory().openSession();
        beginTransaction = session.beginTransaction();
        list = session.createQuery("from ItemOrder where ID_BatchOrder like '" + id + "'").list();
        session.flush();
        session.clear();
        session.getTransaction().commit();
    } catch (HibernateException ex) {
        ex.printStackTrace();
        if (beginTransaction != null) {
            beginTransaction.rollback();
        }
    } finally {
        if (session != null) {
            session.close();
        }
    }
    return list;
}

From source file:autoancillarieslimited.hiberate.dao.OrderDAO.java

public Long getTotalOrder(int id_hw) {
    Long set = null;/*from ww w  .  j a  v a2 s.  c o  m*/
    Session session = null;
    Transaction beginTransaction = null;
    try {
        session = HibernateUtil.getSessionFactory().openSession();
        beginTransaction = session.beginTransaction();
        set = (Long) session
                .createQuery("select count(*) from PurchaseOrder where ID_Warehouse like '" + id_hw + "'")
                .uniqueResult();
        session.flush();
        session.clear();
        session.getTransaction().commit();
    } catch (HibernateException ex) {
        ex.printStackTrace();
        if (beginTransaction != null) {
            beginTransaction.rollback();
        }
    } finally {
        if (session != null) {
            session.close();
        }
    }
    return set;
}

From source file:autoancillarieslimited.hiberate.dao.OrderDAO.java

public Long getTotalOrderByWarehouse(int id_hw, String dateFrom, String dateTo) {
    Long set = null;// w  w w . ja va  2  s  .c o  m
    Session session = null;
    Transaction beginTransaction = null;
    try {
        session = HibernateUtil.getSessionFactory().openSession();
        beginTransaction = session.beginTransaction();
        set = (Long) session
                .createQuery("select count(*) from PurchaseOrder where ID_Warehouse like '" + id_hw
                        + "' AND Date_Order >='" + dateFrom + "' AND Date_Order <='" + dateTo + "'")
                .uniqueResult();
        session.flush();
        session.clear();
        session.getTransaction().commit();
    } catch (HibernateException ex) {
        ex.printStackTrace();
        if (beginTransaction != null) {
            beginTransaction.rollback();
        }
    } finally {
        if (session != null) {
            session.close();
        }
    }
    return set;
}

From source file:autoancillarieslimited.hiberate.dao.OrderDAO.java

public Long getTotalOrder(int id_hw, String dateFrom, String dateTo) {
    Long set = null;/*from  w w  w . j a  v  a 2 s .  c om*/
    Session session = null;
    Transaction beginTransaction = null;
    try {
        session = HibernateUtil.getSessionFactory().openSession();
        beginTransaction = session.beginTransaction();
        set = (Long) session
                .createQuery("select count(*) from PurchaseOrder where Status like '" + id_hw
                        + "' AND Date_Order >='" + dateFrom + "' AND Date_Order <='" + dateTo + "'")
                .uniqueResult();
        session.flush();
        session.clear();
        session.getTransaction().commit();
    } catch (HibernateException ex) {
        ex.printStackTrace();
        if (beginTransaction != null) {
            beginTransaction.rollback();
        }
    } finally {
        if (session != null) {
            session.close();
        }
    }
    return set;
}

From source file:autoancillarieslimited.hiberate.dao.OrderDAO.java

public Long getTotalOrder(int id_wh, int status) {
    Long set = null;//from w  w w  .  j  a  v a 2 s .  c  om
    Session session = null;
    Transaction beginTransaction = null;
    try {
        session = HibernateUtil.getSessionFactory().openSession();
        beginTransaction = session.beginTransaction();
        set = (Long) session.createQuery("select count(*) from PurchaseOrder where ID_Warehouse like '" + id_wh
                + "' AND Status like '" + status + "'").uniqueResult();
        session.flush();
        session.clear();
        session.getTransaction().commit();
    } catch (HibernateException ex) {
        ex.printStackTrace();
        if (beginTransaction != null) {
            beginTransaction.rollback();
        }
    } finally {
        if (session != null) {
            session.close();
        }
    }
    return set;
}

From source file:autoancillarieslimited.hiberate.dao.OrderDAO.java

public Long getTotalOrder(int id_wh, int status, String dateFrom, String dateTo) {
    Long set = null;//from w ww  .  j a v  a  2 s. c o  m
    Session session = null;
    Transaction beginTransaction = null;
    try {
        session = HibernateUtil.getSessionFactory().openSession();
        beginTransaction = session.beginTransaction();
        set = (Long) session.createQuery(
                "select count(*) from PurchaseOrder where ID_Warehouse like '" + id_wh + "' AND Status like '"
                        + status + "'  AND Date_Order >='" + dateFrom + "' AND Date_Order <='" + dateTo + "'")
                .uniqueResult();
        session.flush();
        session.clear();
        session.getTransaction().commit();
    } catch (HibernateException ex) {
        ex.printStackTrace();
        if (beginTransaction != null) {
            beginTransaction.rollback();
        }
    } finally {
        if (session != null) {
            session.close();
        }
    }
    return set;
}

From source file:autoancillarieslimited.hiberate.dao.OrderDAO.java

public Long getTotalOrder() {
    Long set = null;/*from  w  w  w .j  a v a  2 s  .com*/
    Session session = null;
    Transaction beginTransaction = null;
    try {
        session = HibernateUtil.getSessionFactory().openSession();
        beginTransaction = session.beginTransaction();
        set = (Long) session.createQuery("select count(*) from PurchaseOrder").uniqueResult();
        session.flush();
        session.clear();
        session.getTransaction().commit();
    } catch (HibernateException ex) {
        ex.printStackTrace();
        if (beginTransaction != null) {
            beginTransaction.rollback();
        }
    } finally {
        if (session != null) {
            session.close();
        }
    }
    return set;
}