List of usage examples for org.hibernate Session createQuery
@Override org.hibernate.query.Query createQuery(CriteriaDelete deleteQuery);
From source file:autoancillarieslimited.hiberate.dao.EmployeeDAO.java
public Employee checkLogin(String email, String password) { Employee item = null;//from w w w.ja va2 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;/*from w w w.ja v a2 s . 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 {// w w w .j a v a 2 s . c om 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;// www . 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;// w w w . ja 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_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 av a 2s .com*/ 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;/* ww w . j a 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_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 w w. ja v a 2s . 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 ww . j av a2s . c om*/ 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; }
From source file:autoancillarieslimited.hiberate.dao.OrderDAO.java
public Long getTotalOrder(String dateFrom, String dateTo) { Long set = null;//from ww w. j a v a2s .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 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; }