List of usage examples for org.hibernate Session flush
void flush() throws HibernateException;
From source file:autoancillarieslimited.hiberate.dao.PurchaseOrderDAO.java
public List<PurchaseOrder> getListByIDWarehouse(int id) { List<PurchaseOrder> set = null; Session session = null; Transaction beginTransaction = null; try {// w w w . j a v a2 s .c o m session = HibernateUtil.getSessionFactory().openSession(); beginTransaction = session.beginTransaction(); set = session.createQuery("from PurchaseOrder where ID_Warehouse 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 set; }
From source file:autoancillarieslimited.hiberate.dao.PurchaseOrderDAO.java
public List<PurchaseOrder> getListByIDWarehouse(int id_wh, String dateFrom, String dateTo, String status) { List<PurchaseOrder> set = null; Session session = null; Transaction beginTransaction = null; try {//from w ww . j av a 2 s .c o m session = HibernateUtil.getSessionFactory().openSession(); beginTransaction = session.beginTransaction(); set = session .createQuery("from PurchaseOrder where ID_Warehouse like '" + id_wh + "' AND Status like '" + status + "' AND Date_Order >='" + dateFrom + "' AND Date_Order <='" + dateTo + "'") .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.PurchaseOrderDAO.java
public List<PurchaseOrder> getListByIDWarehouse(int id_wh, String status) { List<PurchaseOrder> set = null; Session session = null; Transaction beginTransaction = null; try {// w w w.ja v a 2s.c om session = HibernateUtil.getSessionFactory().openSession(); beginTransaction = session.beginTransaction(); set = session.createQuery( "from PurchaseOrder where ID_Warehouse like '" + id_wh + "' AND Status like '" + status + "'") .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.PurchaseOrderDAO.java
public List<PurchaseOrder> getListByIDWarehouse(int id_wh, String dateFrom, String dateTo) { List<PurchaseOrder> set = null; Session session = null; Transaction beginTransaction = null; try {/*from w w w .j a v a 2 s . c o m*/ session = HibernateUtil.getSessionFactory().openSession(); beginTransaction = session.beginTransaction(); set = session.createQuery("from PurchaseOrder where ID_Warehouse like '" + id_wh + "' AND Date_Order >='" + dateFrom + "' AND Date_Order <='" + dateTo + "'").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.PurchaseOrderDAO.java
public List<PurchaseOrder> getListByAdmin(int pageNumber) { List<PurchaseOrder> set = null; Session session = null; Transaction beginTransaction = null; try {/*from w ww .j av a 2 s .c o m*/ session = HibernateUtil.getSessionFactory().openSession(); beginTransaction = session.beginTransaction(); set = session.createQuery("from PurchaseOrder").setFirstResult((pageNumber - 1) * pageSize) .setMaxResults(pageSize).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.PurchaseOrderDAO.java
public List<PurchaseOrder> getListByAdmin(String dateFrom, String dateTo, String status, String warehouse, int pageNumber) { List<PurchaseOrder> set = null; Session session = null; Transaction beginTransaction = null; try {//w w w.j a v a2 s. co m session = HibernateUtil.getSessionFactory().openSession(); beginTransaction = session.beginTransaction(); set = session .createQuery("from PurchaseOrder where ID_Warehouse like '" + warehouse + "' AND Status like '" + status + "' AND Date_Order >='" + dateFrom + "' AND Date_Order <='" + dateTo + "'") .setFirstResult((pageNumber - 1) * pageSize).setMaxResults(pageSize).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.PurchaseOrderDAO.java
public List<PurchaseOrder> getListByAdmin(String status, int pageNumber) { List<PurchaseOrder> set = null; Session session = null; Transaction beginTransaction = null; try {//from w w w. j a va 2 s. c o m session = HibernateUtil.getSessionFactory().openSession(); beginTransaction = session.beginTransaction(); set = session.createQuery("from PurchaseOrder where Status like '" + status + "'") .setFirstResult((pageNumber - 1) * pageSize).setMaxResults(pageSize).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.PurchaseOrderDAO.java
public List<PurchaseOrder> getListByAdmin(String dateFrom, String dateTo, String warehouse, int pageNumber) { List<PurchaseOrder> set = null; Session session = null; Transaction beginTransaction = null; try {/*from w w w . j ava 2 s . c o m*/ session = HibernateUtil.getSessionFactory().openSession(); beginTransaction = session.beginTransaction(); set = session .createQuery("from PurchaseOrder where ID_Warehouse like '" + warehouse + "' AND Date_Order >='" + dateFrom + "' AND Date_Order <='" + dateTo + "'") .setFirstResult((pageNumber - 1) * pageSize).setMaxResults(pageSize).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.PurchaseOrderDAO.java
public List<PurchaseOrder> getListByAdmin(String dateFrom, String dateTo, int pageNumber) { List<PurchaseOrder> set = null; Session session = null; Transaction beginTransaction = null; try {// www .j a v a2 s .c o m session = HibernateUtil.getSessionFactory().openSession(); beginTransaction = session.beginTransaction(); set = session .createQuery("from PurchaseOrder where Date_Order >='" + dateFrom + "' AND Date_Order <='" + dateTo + "'") .setFirstResult((pageNumber - 1) * pageSize).setMaxResults(pageSize).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.PurchaseOrderDAO.java
public Long getCountOrder(String dateFrom, String dateTo, String status, String warehouse) { Long set = null;/*from 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(); if (dateFrom != null && dateTo != null && !dateFrom.equals("") && !dateTo.equals("") && status != null && warehouse != null && !warehouse.equals("all")) { set = (Long) session.createQuery("select count(*) from PurchaseOrder where ID_Warehouse like '" + warehouse + "' AND Date_Order >='" + dateFrom + "' AND Date_Order <='" + dateTo + "' AND Status like '" + status + "'").uniqueResult(); } else { if (dateFrom != null && dateTo != null && !dateFrom.equals("") && !dateTo.equals("") && status != null) { if (Integer.parseInt(status) != -1) { set = (Long) session .createQuery("select count(*) from PurchaseOrder where Date_Order >='" + dateFrom + "' AND Date_Order <='" + dateTo + "' AND Status like '" + status + "'") .uniqueResult(); } else { set = (Long) session.createQuery("select count(*) from PurchaseOrder where Date_Order >='" + dateFrom + "' AND Date_Order <='" + dateTo + "'").uniqueResult(); } } else { 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(); } } long countPage = set / pageSize; if (set % pageSize > 0) { countPage++; } return countPage; }