List of usage examples for org.hibernate Session createQuery
@Override org.hibernate.query.Query createQuery(CriteriaDelete deleteQuery);
From source file:autoancillarieslimited.hiberate.dao.WareHousesDAO.java
public List<WareHouses> getWareHouses() { List<WareHouses> set = null; Session session = null; Transaction beginTransaction = null; try {/*from w w w.j a v a2s .co m*/ session = HibernateUtil.getSessionFactory().openSession(); beginTransaction = session.beginTransaction(); set = session.createQuery("from WareHouses").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.WareHousesDAO.java
public List<WareHouses> getWareHouses(WareHouses filter) { List<WareHouses> set = null; Session session = null; Transaction beginTransaction = null; try {//w ww .ja va2s .c o m session = HibernateUtil.getSessionFactory().openSession(); beginTransaction = session.beginTransaction(); if (filter.getRegion_ID() != 0) { set = session.createQuery("from WareHouses where Name like '%" + filter.getName() + "%' AND Region_ID ='" + filter.getRegion_ID() + "' ").list(); } else { set = session.createQuery("from WareHouses 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.WareHousesDAO.java
public List<Region> getRegion() { List<Region> set = null; Session session = null; Transaction beginTransaction = null; try {//from w w w. j av a 2 s . c o m session = HibernateUtil.getSessionFactory().openSession(); beginTransaction = session.beginTransaction(); set = session.createQuery("from Region").list(); session.getTransaction().commit(); } catch (HibernateException ex) { ex.printStackTrace(); if (beginTransaction != null) { beginTransaction.rollback(); } } finally { if (session != null) { session.close(); } } return set; }
From source file:automatedbillingsoftware_DA.Categories_DA.java
public List<Categories> fetchCategorieses() { SessionFactory sessionFactory = HibernateUtils.getLocSessionFactory(); Session session = sessionFactory.getCurrentSession(); Transaction beginTransaction = session.beginTransaction(); Query query = session.createQuery("from Categories c where c.status=:status"); query.setParameter("status", 1); List<Categories> catList = (List<Categories>) query.list(); beginTransaction.commit();/* w ww . j a v a2 s . co m*/ return catList; }
From source file:automatedbillingsoftware_DA.Categories_DA.java
public Categories fetchCategoryByName(String name) { SessionFactory sessionFactory = HibernateUtils.getLocSessionFactory(); Session session = sessionFactory.openSession(); Transaction beginTransaction = session.beginTransaction(); Query query = session.createQuery("from Categories c where c.status=:status AND c.catName LIKE :name"); query.setParameter("status", 1); query.setParameter("name", name); List<Categories> catList = (List<Categories>) query.list(); beginTransaction.commit();//from ww w. j a va 2s . c o m if (catList.size() > 0) return catList.get(0); else return null; }
From source file:automatedbillingsoftware_DA.Categories_DA.java
public Categories fetchCategoryById(int id) { SessionFactory sessionFactory = HibernateUtils.getLocSessionFactory(); Session session = sessionFactory.openSession(); Transaction beginTransaction = session.beginTransaction(); Query query = session.createQuery("from Categories c where c.catid =:catid AND c.status=:status"); query.setParameter("catid", id); query.setParameter("status", 1); List<Categories> catList = (List<Categories>) query.list(); Categories cat = new Categories(); if (catList.size() > 0) { cat = catList.get(0);// w w w . j a v a2 s.c o m } beginTransaction.commit(); return cat; }
From source file:automatedbillingsoftware_DA.ChallanDA.java
public ChallanGenerated fetchChallanGenById(int id) { SessionFactory sessionFactory = HibernateUtils.getLocSessionFactory(); Session session = sessionFactory.getCurrentSession(); Transaction beginTransaction = session.beginTransaction(); Query query = session.createQuery("from ChallanGenerated where status=:status and id=:id"); query.setParameter("status", 1); query.setParameter("id", id); List<ChallanGenerated> challanList = (List<ChallanGenerated>) query.list(); beginTransaction.commit();// w ww .ja v a 2s .c om return (challanList == null || challanList.size() == 0) ? null : challanList.get(0); }
From source file:automatedbillingsoftware_DA.ChallanDA.java
public Challan fetchChallanByDocNo(String docNo) { SessionFactory sessionFactory = HibernateUtils.getLocSessionFactory(); Session session = sessionFactory.openSession(); Transaction beginTransaction = session.beginTransaction(); Query query = session.createQuery("from Challan where docNo =:docNo"); query.setParameter("docNo", docNo); Challan challan = (Challan) query.list().get(0); beginTransaction.commit();/*from w w w . ja v a 2 s. c om*/ return challan; }
From source file:automatedbillingsoftware_DA.ChallanDA.java
public List<ChallanGenerated> fetchChallanOrders() { SessionFactory sessionFactory = HibernateUtils.getLocSessionFactory(); Session session = sessionFactory.openSession(); Transaction beginTransaction = session.beginTransaction(); Query query = session.createQuery("from ChallanGenerated where status=:status"); query.setParameter("status", 1); List<ChallanGenerated> challanList = (List<ChallanGenerated>) query.list(); beginTransaction.commit();//from w w w .ja v a 2 s. com return challanList; }
From source file:automatedbillingsoftware_DA.ChallanDA.java
public Challan fetchChallanById(int id) { SessionFactory sessionFactory = HibernateUtils.getLocSessionFactory(); Session session = sessionFactory.openSession(); Transaction beginTransaction = session.beginTransaction(); Query query = session.createQuery("from Challan where status=:status AND id=:id"); query.setParameter("status", 1); query.setParameter("id", id); List<Challan> challanList = (List<Challan>) query.list(); beginTransaction.commit();// ww w.j av a2s .c o m return challanList == null || challanList.size() <= 0 ? null : challanList.get(0); }