List of usage examples for org.hibernate Session createQuery
@Override org.hibernate.query.Query createQuery(CriteriaDelete deleteQuery);
From source file:automatedbillingsoftware_DA.ChallanDA.java
public Challan fetchChallansByDocNameAndDocNo(String docName) { SessionFactory sessionFactory = HibernateUtils.getLocSessionFactory(); Session session = sessionFactory.openSession(); Transaction beginTransaction = session.beginTransaction(); Query query = session.createQuery("from Challan where status=:status AND documentName LIKE :docName"); query.setParameter("status", 1); query.setParameter("docName", docName); List<Challan> challanList = (List<Challan>) query.list(); beginTransaction.commit();/*from ww w . j a v a2 s. c om*/ return challanList == null ? null : challanList.get(0); }
From source file:automatedbillingsoftware_DA.ChallanDA.java
public List<Challan> fetchAllChallanList() { SessionFactory sessionFactory = HibernateUtils.getLocSessionFactory(); Session session = sessionFactory.getCurrentSession(); Transaction beginTransaction = session.beginTransaction(); Query query = session.createQuery("from Challan where status=:status"); query.setParameter("status", 1); List<Challan> challanList = (List<Challan>) query.list(); beginTransaction.commit();//from w w w.j a va 2s. co m return challanList; }
From source file:automatedbillingsoftware_DA.ChallanDA.java
public void deleteChallan(int id) { SessionFactory sessionFactory = HibernateUtils.getLocSessionFactory(); Session session = sessionFactory.getCurrentSession(); 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(); Challan challan = challanList.get(0); challan.setStatus(0);//from w ww .ja v a 2 s .c o m session.update(challan); beginTransaction.commit(); }
From source file:automatedbillingsoftware_DA.CompanyDetailsDA.java
public Company fetchCompanyDetailsByUserIdandPass(String user, String pass) { Company comp = null;/*from ww w .jav a 2 s.co m*/ SessionFactory sessionFactory = HibernateUtils.getLocSessionFactory(); Session session = sessionFactory.openSession(); session.beginTransaction(); Query query = session.createQuery("from Company comp where comp.password=:pass and comp.name=:name"); query.setParameter("name", user); query.setParameter("pass", pass); List list = query.list(); if (list != null && list.size() > 0) { comp = (Company) list.get(0); } session.getTransaction().commit(); return comp; }
From source file:automatedbillingsoftware_DA.CompanyDetailsDA.java
public List<Company> fetchCompanyList() { SessionFactory sessionFactory = HibernateUtils.getLocSessionFactory(); Session session = sessionFactory.openSession(); session.beginTransaction();/*from w w w. ja v a 2 s .co m*/ Query query = session.createQuery("from Company comp"); List<Company> compList = query.list(); session.getTransaction().commit(); return compList; }
From source file:automatedbillingsoftware_DA.CompanyDetailsDA.java
public void updateCurrentCompany(Company comp) { SessionFactory sessionFactory = HibernateUtils.getLocSessionFactory(); Session session = sessionFactory.getCurrentSession(); session.beginTransaction();// w ww . ja v a 2 s .co m Query query = session.createQuery("from Company c where c.companyId=:id"); query.setParameter("id", UserSession.getCompany().getCompanyId()); Company com = (Company) query.list().get(0); com.setAddress(comp.getAddress()); com.setCompanyName(comp.getCompanyName()); com.setCountry(comp.getCountry()); com.setDateOfInsertion(comp.getDateOfInsertion()); com.setEmail(comp.getEmail()); com.setLogo(comp.getLogo()); com.setName(comp.getName()); com.setPanNo(comp.getPanNo()); com.setPassword(comp.getPassword()); com.setPhone(comp.getPhone()); com.setStatus(1); com.setTax(comp.getTax()); com.setVatNo(comp.getVatNo()); com.setWebsite(comp.getWebsite()); session.update(com); UserSession.setCompany(com); session.getTransaction().commit(); }
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 ww . j a v a2 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. ja v a 2 s . c o 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);/*w w w. j a va2s . c o m*/ 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);/*from w w w . j av a2s .c o m*/ beginTransaction.commit(); return get; }