List of usage examples for org.hibernate Session createQuery
@Override org.hibernate.query.Query createQuery(CriteriaDelete deleteQuery);
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 w w . j a v a2 s . co m*/ 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();//ww w. ja va 2s .com 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();/* w w w .ja va 2 s. co 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 ww w . j a va 2s.c om*/ 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();// ww w. j ava2s . c om 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 v a 2s . c o m*/ return tax; }
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 w w . j av a 2 s.c o m*/ session.close(); return templeteList != null && templeteList.size() > 0 ? templeteList.get(0) : null; }
From source file:automatedbillingsoftware_DA.User_DA.java
public List<Users> fetchAllUser(Users users) { SessionFactory sessionFactory = HibernateUtils.getLocSessionFactory(); Session session = sessionFactory.getCurrentSession(); Transaction beginTransaction = session.beginTransaction(); Query query = session.createQuery("from Users where status=:status"); query.setParameter("status", 1); List<Users> list = (List<Users>) query.list(); // session.saveOrUpdate(users); beginTransaction.commit();/*from ww w . j a v a 2 s .co m*/ // return users; return list; }
From source file:automatedbillingsoftware_DA.User_DA.java
public Users fetchUserById(int id) { SessionFactory sessionFactory = HibernateUtils.getLocSessionFactory(); Session session = sessionFactory.getCurrentSession(); Transaction beginTransaction = session.beginTransaction(); Query query = session.createQuery("from Users where status=:status and userid=:id"); query.setParameter("status", 1); query.setParameter("userid", id); List<Users> list = (List<Users>) query.list(); // session.saveOrUpdate(users); beginTransaction.commit();//ww w. j a va2 s. co m // return users; return (Users) list.get(0); }
From source file:ayarlar.ayarlar.java
public void datagetir() { SessionFactory sf = NewHibernateUtil.getSessionFactory(); Session sesi = sf.openSession(); Transaction tr = sesi.beginTransaction(); List<Admin> ls = sesi.createQuery("from Admin").list(); for (Admin item : ls) { jTextField1.setText(item.getAdminAdi()); jTextField2.setText(item.getAdminSoyadi()); jTextField3.setText(item.getAdminMail()); jTextField4.setText(item.getAdminTelefon()); jTextField5.setText(item.getAdminKadi()); jPasswordField1.requestFocus();//from ww w. j av a 2 s .co m } tr.commit(); }