List of usage examples for org.hibernate SessionFactory openSession
Session openSession() throws HibernateException;
From source file:automatedbillingsoftware_DA.ChallanDA.java
public Challan updateChallan(Challan challan) { SessionFactory sessionFactory = HibernateUtils.getLocSessionFactory(); Session session = sessionFactory.openSession(); Transaction beginTransaction = session.beginTransaction(); session.update(challan);/* ww w .j a va 2 s. co m*/ beginTransaction.commit(); 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 . j a va 2s .c om*/ 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();// w w w . j a v a 2 s .com return challanList == null || challanList.size() <= 0 ? null : challanList.get(0); }
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 w ww. j av a2 s . c om*/ return challanList == null ? null : challanList.get(0); }
From source file:automatedbillingsoftware_DA.CompanyDetailsDA.java
public void addCompany(Company comp) { SessionFactory sessionFactory = HibernateUtils.getLocSessionFactory(); Session session = sessionFactory.openSession(); session.beginTransaction();/* w w w . j a va 2s. co m*/ session.persist(comp); session.getTransaction().commit(); }
From source file:automatedbillingsoftware_DA.CompanyDetailsDA.java
public Company fetchCompanyDetailsByUserIdandPass(String user, String pass) { Company comp = null;/*ww w. j a v a 2 s . c om*/ 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 . j av a 2s . c om Query query = session.createQuery("from Company comp"); List<Company> compList = query.list(); session.getTransaction().commit(); return compList; }
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 www.j a va 2s. c o m return list; }
From source file:automatedbillingsoftware_DA.Templete_DA.java
public Templete addTemplete(Templete templete) { SessionFactory sessionFactory = HibernateUtils.getLocSessionFactory(); Session session = sessionFactory.openSession(); Transaction beginTransaction = session.beginTransaction(); session.persist(templete);//from w ww . ja va 2s . c o m beginTransaction.commit(); session.close(); return templete; }
From source file:automatedbillingsoftware_DA.Templete_DA.java
public Templete fetchTempleteByName(String tempName) { SessionFactory sessionFactory = HibernateUtils.getLocSessionFactory(); Session session = sessionFactory.openSession(); Transaction beginTransaction = session.beginTransaction(); Query query = session.createQuery("from Templete where status=:status and name LIKE:name"); query.setParameter("status", 1); query.setParameter("name", tempName); List<Templete> templeteList = (List<Templete>) query.list(); beginTransaction.commit();// w ww .j a v a 2 s. c o m session.close(); return templeteList != null && templeteList.size() > 0 ? templeteList.get(0) : null; }