List of usage examples for org.hibernate Query setParameter
@SuppressWarnings("unchecked") Query<R> setParameter(int position, Object val);
From source file:automatedbillingsoftware_DA.InvoiceReport_DA.java
public List<InvoiceReport> fetchAllInvoiceReport() { SessionFactory sessionFactory = HibernateUtils.getLocSessionFactory(); Session session = sessionFactory.getCurrentSession(); Transaction beginTransaction = session.beginTransaction(); Query query = session.createQuery("from InvoiceReport where status =:status"); query.setParameter("status", 1); List<InvoiceReport> invoiceReportList = query.list(); beginTransaction.commit();/* w w w. j a va2 s . c o m*/ return invoiceReportList; }
From source file:automatedbillingsoftware_DA.InvoiceReport_DA.java
public List<InvoiceReport> searchInvoiceReport(Date frmDate, Date toDate, int orderNo, String docName, int docNo) { List<InvoiceReport> invoiceList = new LinkedList<>(); SessionFactory sessionFactory = HibernateUtils.getLocSessionFactory(); Session session = sessionFactory.getCurrentSession(); Transaction beginTransaction = session.beginTransaction(); Query query = session.createQuery("from InvoiceReport where status =:status"); query.setParameter("status", 1); List<InvoiceReport> invoiceReportList = query.list(); List<InvoiceReport> searchList = new LinkedList<>(); for (int i = 0; i < invoiceReportList.size(); i++) { if (invoiceReportList.get(i).getOrderNo() == (double) orderNo || (invoiceReportList.get(i).getBillDate().compareTo(toDate) <= 0 && invoiceReportList.get(i).getBillDate().compareTo(frmDate) >= 0) || new ChallanBL().fetchChallanByDocName(docName) != null) { searchList.add(invoiceReportList.get(i)); }//from w w w . j a v a2 s.co m } beginTransaction.commit(); System.out.println("searchList=>" + searchList); return searchList; }
From source file:automatedbillingsoftware_DA.Products_DA.java
public void deleteProducts(int id) { SessionFactory sessionFactory = HibernateUtils.getLocSessionFactory(); Session session = sessionFactory.getCurrentSession(); Transaction beginTransaction = session.beginTransaction(); Query query = session.createQuery("from Products p where p.status=:status AND p.prodid=:id"); query.setParameter("status", 1); query.setParameter("id", id); List<Products> list = (List<Products>) query.list(); Products get = list.get(0);//from w w w.jav a 2 s . com get.setStatus(0); session.update(get); beginTransaction.commit(); }
From source file:automatedbillingsoftware_DA.Products_DA.java
public Products fetchProductById(int id) { SessionFactory sessionFactory = HibernateUtils.getLocSessionFactory(); Session session = sessionFactory.getCurrentSession(); Transaction beginTransaction = session.beginTransaction(); Query query = session.createQuery("from Products p where p.status=:status AND p.prodid=:id"); query.setParameter("status", 1); query.setParameter("id", id); List<Products> list = (List<Products>) query.list(); Products get = list.get(0);/* w w w .j a v a2 s. c o m*/ beginTransaction.commit(); return get; }
From source file:automatedbillingsoftware_DA.Products_DA.java
public List<Products> fetchAllProducts() { SessionFactory sessionFactory = HibernateUtils.getLocSessionFactory(); Session session = sessionFactory.getCurrentSession(); Transaction beginTransaction = session.beginTransaction(); Query query = session.createQuery("from Products p where status=:status"); query.setParameter("status", 1); List<Products> list = (List<Products>) query.list(); beginTransaction.commit();/*w ww. j av a 2s.com*/ return list; }
From source file:automatedbillingsoftware_DA.Products_DA.java
public List<Products> fetchProductByQRCode(String qrcode) { SessionFactory sessionFactory = HibernateUtils.getLocSessionFactory(); Session session = sessionFactory.getCurrentSession(); Transaction beginTransaction = session.beginTransaction(); Query query = session.createQuery("from Products p where status =:status and qrCode=:code"); query.setParameter("status", 1); query.setParameter("code", qrcode); List<Products> list = (List<Products>) query.list(); System.out.println(qrcode + "list.size=>" + list.size()); beginTransaction.commit();/*from w ww .j a v a2s . c o m*/ return list; }
From source file:automatedbillingsoftware_DA.Products_DA.java
public Products fetchProductByName(String name) { SessionFactory sessionFactory = HibernateUtils.getLocSessionFactory(); Session session = sessionFactory.getCurrentSession(); Transaction beginTransaction = session.beginTransaction(); Query query = session.createQuery("from Products p where status =:status and prodName=:name"); query.setParameter("status", 1); query.setParameter("name", name); List<Products> list = (List<Products>) query.list(); beginTransaction.commit();//from ww w . j av a 2 s . c o m return (Products) (list.size() > 0 ? list.get(0) : null); }
From source file:automatedbillingsoftware_DA.TaxDA.java
public List<Tax> fetchAllTaxList() { SessionFactory sessionFactory = HibernateUtils.getLocSessionFactory(); Session session = sessionFactory.openSession(); Transaction beginTransaction = session.beginTransaction(); Query query = session.createQuery("from Tax t where t.status=:status"); query.setParameter("status", 1); List<Tax> list = (List<Tax>) query.list(); beginTransaction.commit();//from w w w. ja va2 s .c o m return list; }
From source file:automatedbillingsoftware_DA.TaxDA.java
public Tax fetchTaxByName(String name) { SessionFactory sessionFactory = HibernateUtils.getLocSessionFactory(); Session session = sessionFactory.getCurrentSession(); Transaction beginTransaction = session.beginTransaction(); Query query = session.createQuery("from Tax t where t.taxName LIKE :taxName AND t.status=:status"); query.setParameter("status", 1); query.setParameter("taxName", name); Tax tax = (Tax) query.list().get(0); beginTransaction.commit();/*from www . jav a 2 s .c o m*/ return tax; }
From source file:automatedbillingsoftware_DA.TaxDA.java
public Tax fetchTaxById(int id) { SessionFactory sessionFactory = HibernateUtils.getLocSessionFactory(); Session session = sessionFactory.getCurrentSession(); Transaction beginTransaction = session.beginTransaction(); Query query = session.createQuery("from Tax t where t.taxId=:taxId AND t.status=:status"); query.setParameter("status", 1); query.setParameter("taxId", id); Tax tax = (Tax) query.list().get(0); beginTransaction.commit();/* w w w .j a va2 s . c om*/ return tax; }