Example usage for org.hibernate Query iterate

List of usage examples for org.hibernate Query iterate

Introduction

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

Prototype

Iterator<R> iterate();

Source Link

Document

Return the query results as an Iterator.

Usage

From source file:com.mss.mirage.util.HibernateDataProvider.java

License:Open Source License

public List getIndustry(String lKIndustryKey) throws ServiceLocatorException {

    List lKIndustryList = new ArrayList();//Description

    /*  if (CacheManager.getCache().containsKey(lKIndustryKey)) {
    lKIndustryList  = (List) CacheManager.getCache().get(lKIndustryKey);
      } else {*//* ww  w .  j a v a  2s .c  om*/
    //getting sessionFactory for the HibernateUtil class.
    Session session = HibernateServiceLocator.getInstance().getSession();
    //Creating a transaction for the session object.
    Transaction tran = session.beginTransaction();
    //Genarating a quary for retrieving the data from the database.
    String SQL_STG = "select tp.description from LKIndustryData as tp";
    Query query = session.createQuery(SQL_STG);
    for (Iterator it = query.iterate(); it.hasNext();) {
        String desc = (String) it.next();
        //Storing values into the TreeList.
        lKIndustryList.add(desc);

    } // closing for loop.

    //  CacheManager.getCache().put(lKIndustryKey, lKIndustryList);

    try {
        // Closing hibernate session
        session.close();
        session = null;
    } catch (HibernateException he) {
        throw new ServiceLocatorException(he);
    } finally {
        if (session != null) {
            try {
                session.close();
                session = null;
            } catch (HibernateException he) {
                throw new ServiceLocatorException(he);
            }
        }
    }

    // }// closing if condition.

    return lKIndustryList;// returning the object.
}

From source file:com.mss.mirage.util.HibernateDataProvider.java

License:Open Source License

public List getRecConsultant(String recConsultantKey) throws ServiceLocatorException {

    List recConsultantTypesList = new ArrayList();//Description

    if (CacheManager.getCache().containsKey(recConsultantKey)) {
        recConsultantTypesList = (List) CacheManager.getCache().get(recConsultantKey);
    } else {//  www.j  a v a2  s.  co m
        //getting sessionFactory for the HibernateUtil class.
        Session session = HibernateServiceLocator.getInstance().getSession();
        //Creating a transaction for the session object.
        Transaction tran = session.beginTransaction();
        //Genarating a quary for retrieving the data from the database.
        String SQL_STG = "select tp.description from RecConsultantData as tp";
        Query query = session.createQuery(SQL_STG);
        for (Iterator it = query.iterate(); it.hasNext();) {
            String desc = (String) it.next();
            //Storing values into the TreeList.
            recConsultantTypesList.add(desc);

        } // closing for loop.

        CacheManager.getCache().put(recConsultantKey, recConsultantTypesList);

        try {
            // Closing hibernate session
            session.close();
            session = null;
        } catch (HibernateException he) {
            throw new ServiceLocatorException(he);
        } finally {
            if (session != null) {
                try {
                    session.close();
                    session = null;
                } catch (HibernateException he) {
                    throw new ServiceLocatorException(he);
                }
            }
        }

    } // closing if condition.

    return recConsultantTypesList;// returning the object.
}

From source file:com.mss.mirage.util.HibernateDataProvider.java

License:Open Source License

public List getCrmAccountType(String crmAccountKey) throws ServiceLocatorException {

    List crmAccountTypesList = new ArrayList();//Description

    if (CacheManager.getCache().containsKey(crmAccountKey)) {
        crmAccountTypesList = (List) CacheManager.getCache().get(crmAccountKey);
    } else {//from w w w . j a v a  2s .c  om
        //getting sessionFactory for the HibernateUtil class.
        Session session = HibernateServiceLocator.getInstance().getSession();
        //Creating a transaction for the session object.
        Transaction tran = session.beginTransaction();
        //Genarating a quary for retrieving the data from the database.
        String SQL_STG = "select tp.description from CrmAccountData as tp";
        Query query = session.createQuery(SQL_STG);
        for (Iterator it = query.iterate(); it.hasNext();) {
            String desc = (String) it.next();
            //Storing values into the TreeList.
            crmAccountTypesList.add(desc);

        } // closing for loop.

        CacheManager.getCache().put(crmAccountKey, crmAccountTypesList);

        try {
            // Closing hibernate session
            session.close();
            session = null;
        } catch (HibernateException he) {
            throw new ServiceLocatorException(he);
        } finally {
            if (session != null) {
                try {
                    session.close();
                    session = null;
                } catch (HibernateException he) {
                    throw new ServiceLocatorException(he);
                }
            }
        }

    } // closing if condition.

    return crmAccountTypesList;// returning the object.
}

From source file:com.mss.mirage.util.HibernateDataProvider.java

License:Open Source License

public List getCrmAccountStatus(String crmAccountStatusKey) throws ServiceLocatorException {

    List crmAccountStatusTypesList = new ArrayList();//Description

    if (CacheManager.getCache().containsKey(crmAccountStatusKey)) {
        crmAccountStatusTypesList = (List) CacheManager.getCache().get(crmAccountStatusKey);
    } else {//from   www . j ava 2 s.c  o  m
        //getting sessionFactory for the HibernateUtil class.
        Session session = HibernateServiceLocator.getInstance().getSession();
        //Creating a transaction for the session object.
        Transaction tran = session.beginTransaction();
        //Genarating a quary for retrieving the data from the database.
        String SQL_STG = "select tp.description from CrmAccountStatusData as tp";
        Query query = session.createQuery(SQL_STG);
        for (Iterator it = query.iterate(); it.hasNext();) {
            String desc = (String) it.next();
            //Storing values into the TreeList.
            crmAccountStatusTypesList.add(desc.trim());

        } // closing for loop.

        CacheManager.getCache().put(crmAccountStatusKey, crmAccountStatusTypesList);

        try {
            // Closing hibernate session
            session.close();
            session = null;
        } catch (HibernateException he) {
            throw new ServiceLocatorException(he);
        } finally {
            if (session != null) {
                try {
                    session.close();
                    session = null;
                } catch (HibernateException he) {
                    throw new ServiceLocatorException(he);
                }
            }
        }

    } // closing if condition.
      //System.out.println("crmAccountStatusKey-->"+crmAccountStatusTypesList.size());
    return crmAccountStatusTypesList;// returning the object.
}

From source file:com.mss.mirage.util.HibernateDataProvider.java

License:Open Source License

public List getCrmActivityTypes(String crmActivityTypeKey) throws ServiceLocatorException {

    List crmActivityTypesList = new ArrayList();//Description

    if (CacheManager.getCache().containsKey(crmActivityTypeKey)) {
        crmActivityTypesList = (List) CacheManager.getCache().get(crmActivityTypeKey);
    } else {//from w  ww  . ja va 2s .  com
        //getting sessionFactory for the HibernateUtil class.
        Session session = HibernateServiceLocator.getInstance().getSession();
        //Creating a transaction for the session object.
        Transaction tran = session.beginTransaction();
        //Genarating a quary for retrieving the data from the database.
        //String SQL_STG="select tp.description from CrmActivityData as tp";
        //newly added on 03282013
        String SQL_STG = "select tp.description from CrmActivityData as tp where tp.status = 'Active'";
        Query query = session.createQuery(SQL_STG);
        for (Iterator it = query.iterate(); it.hasNext();) {
            String desc = (String) it.next();
            //Storing values into the TreeList.
            crmActivityTypesList.add(desc);

        } // closing for loop.
          //Sorting Elements
        Collections.sort(crmActivityTypesList);
        CacheManager.getCache().put(crmActivityTypeKey, crmActivityTypesList);

        try {
            // Closing hibernate session
            session.close();
            session = null;
        } catch (HibernateException he) {
            throw new ServiceLocatorException(he);
        } finally {
            if (session != null) {
                try {
                    session.close();
                    session = null;
                } catch (HibernateException he) {
                    throw new ServiceLocatorException(he);
                }
            }
        }
    } // closing if condition.

    return crmActivityTypesList;// returning the object.
}

From source file:com.mss.mirage.util.HibernateDataProvider.java

License:Open Source License

public List getCrmAddress(String crmAddressKey) throws ServiceLocatorException {

    List crmAddressTypesList = new ArrayList();//Description

    if (CacheManager.getCache().containsKey(crmAddressKey)) {
        crmAddressTypesList = (List) CacheManager.getCache().get(crmAddressKey);
    } else {/*from w  w w  .  j a v a2s .  c  o m*/
        //getting sessionFactory for the HibernateUtil class.
        Session session = HibernateServiceLocator.getInstance().getSession();
        //Creating a transaction for the session object.
        Transaction tran = session.beginTransaction();
        //Genarating a quary for retrieving the data from the database.
        String SQL_STG = "select tp.description from CrmAddressData as tp";
        Query query = session.createQuery(SQL_STG);
        for (Iterator it = query.iterate(); it.hasNext();) {
            String desc = (String) it.next();
            //Storing values into the TreeList.
            crmAddressTypesList.add(desc);

        } // closing for loop.

        CacheManager.getCache().put(crmAddressKey, crmAddressTypesList);

        try {
            // Closing hibernate session
            session.close();
            session = null;
        } catch (HibernateException he) {
            throw new ServiceLocatorException(he);
        } finally {
            if (session != null) {
                try {
                    session.close();
                    session = null;
                } catch (HibernateException he) {
                    throw new ServiceLocatorException(he);
                }
            }
        }

    } // closing if condition.

    return crmAddressTypesList;// returning the object.
}

From source file:com.mss.mirage.util.HibernateDataProvider.java

License:Open Source License

public List getObject(String objectKey) throws ServiceLocatorException {

    List objectList = new ArrayList();//Description

    if (CacheManager.getCache().containsKey(objectKey)) {
        objectList = (List) CacheManager.getCache().get(objectKey);
    } else {/*from w w  w  .  jav a2 s .  com*/
        //getting sessionFactory for the HibernateUtil class.
        Session session = HibernateServiceLocator.getInstance().getSession();
        //Creating a transaction for the session object.
        Transaction tran = session.beginTransaction();
        //Genarating a quary for retrieving the data from the database.
        String SQL_STG = "select tp.description from ObjectData as tp";
        Query query = session.createQuery(SQL_STG);
        for (Iterator it = query.iterate(); it.hasNext();) {
            String desc = (String) it.next();
            //Storing values into the TreeList.
            objectList.add(desc);

        } // closing for loop.

        CacheManager.getCache().put(objectKey, objectList);

        try {
            // Closing hibernate session
            session.close();
            session = null;
        } catch (HibernateException he) {
            throw new ServiceLocatorException(he);
        } finally {
            if (session != null) {
                try {
                    session.close();
                    session = null;
                } catch (HibernateException he) {
                    throw new ServiceLocatorException(he);
                }
            }
        }

    } // closing if condition.

    return objectList;// returning the object.
}

From source file:com.mss.mirage.util.HibernateDataProvider.java

License:Open Source License

public List getEmployeeType(String employeeTypeKey) throws ServiceLocatorException {

    List employeeTypesList = new ArrayList();//Description

    if (CacheManager.getCache().containsKey(employeeTypeKey)) {
        employeeTypesList = (List) CacheManager.getCache().get(employeeTypeKey);
    } else {//from w  w w. j  a va2 s .c om
        //getting sessionFactory for the HibernateUtil class.
        Session session = HibernateServiceLocator.getInstance().getSession();
        //Creating a transaction for the session object.
        Transaction tran = session.beginTransaction();
        //Genarating a quary for retrieving the data from the database.
        String SQL_STG = "select tp.description from EmployeeTypeData as tp";
        Query query = session.createQuery(SQL_STG);
        for (Iterator it = query.iterate(); it.hasNext();) {
            String desc = (String) it.next();
            //Storing values into the TreeList.
            employeeTypesList.add(desc);

        } // closing for loop.

        CacheManager.getCache().put(employeeTypeKey, employeeTypesList);

        try {
            // Closing hibernate session
            session.close();
            session = null;
        } catch (HibernateException he) {
            throw new ServiceLocatorException(he);
        } finally {
            if (session != null) {
                try {
                    session.close();
                    session = null;
                } catch (HibernateException he) {
                    throw new ServiceLocatorException(he);
                }
            }
        }

    } // closing if condition.

    return employeeTypesList;// returning the object.
}

From source file:com.mss.mirage.util.HibernateDataProvider.java

License:Open Source License

public List getStage(String stageKey) throws ServiceLocatorException {

    List stageList = new ArrayList();//Description

    if (CacheManager.getCache().containsKey(stageKey)) {
        stageList = (List) CacheManager.getCache().get(stageKey);
    } else {/*from   www .j a v  a2 s.c om*/
        //getting sessionFactory for the HibernateUtil class.
        Session session = HibernateServiceLocator.getInstance().getSession();
        //Creating a transaction for the session object.
        Transaction tran = session.beginTransaction();
        //Genarating a quary for retrieving the data from the database.
        String SQL_STG = "select tp.description from StageData as tp";
        Query query = session.createQuery(SQL_STG);
        for (Iterator it = query.iterate(); it.hasNext();) {
            String desc = (String) it.next();
            //Storing values into the TreeList.
            stageList.add(desc);

        } // closing for loop.

        CacheManager.getCache().put(stageKey, stageList);

        try {
            // Closing hibernate session
            session.close();
            session = null;
        } catch (HibernateException he) {
            throw new ServiceLocatorException(he);
        } finally {
            if (session != null) {
                try {
                    session.close();
                    session = null;
                } catch (HibernateException he) {
                    throw new ServiceLocatorException(he);
                }
            }
        }

    } // closing if condition.

    return stageList;// returning the object.
}

From source file:com.mss.mirage.util.HibernateDataProvider.java

License:Open Source License

public List getOpportunityType(String opportunitytypeKey) throws ServiceLocatorException {

    List opportunitytypeList = new ArrayList(); //Description

    if (CacheManager.getCache().containsKey(opportunitytypeKey)) {
        opportunitytypeList = (List) CacheManager.getCache().get(opportunitytypeKey);
    } else {//from  w  w w . j  a v  a2s.  c om
        //getting sessionFactory for the HibernateUtil class.
        Session session = HibernateServiceLocator.getInstance().getSession();
        //Creating a transaction for the session object.
        Transaction tran = session.beginTransaction();
        //Genarating a quary for retrieving the data from the database.
        String SQL_STG = "select tp.description from opportunitytypeData as tp";
        Query query = session.createQuery(SQL_STG);
        for (Iterator it = query.iterate(); it.hasNext();) {
            String desc = (String) it.next();
            //Storing values into the TreeList.
            opportunitytypeList.add(desc);

        } // closing for loop.

        CacheManager.getCache().put(opportunitytypeKey, opportunitytypeList);

        try {
            // Closing hibernate session
            session.close();
            session = null;
        } catch (HibernateException he) {
            throw new ServiceLocatorException(he);
        } finally {
            if (session != null) {
                try {
                    session.close();
                    session = null;
                } catch (HibernateException he) {
                    throw new ServiceLocatorException(he);
                }
            }
        }

    } // closing if condition.
    Collections.sort(opportunitytypeList);
    return opportunitytypeList;// returning the object.
}