List of usage examples for org.hibernate Session clear
void clear();
From source file:autoancillarieslimited.hiberate.dao.EmployeeDAO.java
public List<Employee> getEmployees(Employee filter) { List<Employee> set = null; Session session = null; Transaction beginTransaction = null; try {//from w w w . java 2s . c om session = HibernateUtil.getSessionFactory().openSession(); beginTransaction = session.beginTransaction(); if (filter.getWareHouses_ID() != 0) { set = session.createQuery("from Employee where Name like '%" + filter.getName() + "%' AND WareHouses_ID ='" + filter.getWareHouses_ID() + "' ").list(); } else { set = session.createQuery("from Employee where Name like '%" + filter.getName() + "%'").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 List<Employee> getEmployees() { List<Employee> set = null; Session session = null; Transaction beginTransaction = null; try {//from www .jav a 2 s . co 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 .ja v a2s . c om*/ 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;/*from w w w . j av a2s .c o m*/ 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 {/*from ww w .j a v a2s. c o m*/ 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;//ww w . j a va 2s . 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_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;//from 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;/* w w w . ja v a2 s. co m*/ 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;//w w 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_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;/* ww w . 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; }