Example usage for org.hibernate Query list

List of usage examples for org.hibernate Query list

Introduction

In this page you can find the example usage for org.hibernate Query list.

Prototype

List<R> list();

Source Link

Document

Return the query results as a List.

Usage

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();/* www .  ja  va2 s.  c  o  m*/
    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   www .  j a  v a2 s.c  o  m*/

    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  ww  .j  a  va2 s.c  o m

    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();//w w  w .  j a va 2s .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   ww  w .jav a2 s  . c  om

    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);//  w w  w.ja v  a2  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  w  w  w. j  a  v  a2  s .  c  o 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 ww w. j a va2  s  .c  o 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();/*from ww w . ja  v  a 2  s . c  o  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 w w  .  j  a v  a2 s . c  om*/
    return invoiceReportList;
}