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 getCrmContactStatus(String crmContactStatusKey) throws ServiceLocatorException {

    List crmContactStatusList = new ArrayList();//Description

    if (CacheManager.getCache().containsKey(crmContactStatusKey)) {
        crmContactStatusList = (List) CacheManager.getCache().get(crmContactStatusKey);
    } else {/*  w  w w  . ja v  a 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 CrmContactStatusData 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.
            crmContactStatusList.add(desc);

        } // closing for loop.

        CacheManager.getCache().put(crmContactStatusKey, crmContactStatusList);

        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 crmContactStatusList;// returning the object.
}

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

License:Open Source License

public List getCrmContactType(String crmContactTypeKey) throws ServiceLocatorException {

    List crmContactTypeList = new ArrayList();//Description

    if (CacheManager.getCache().containsKey(crmContactTypeKey)) {
        crmContactTypeList = (List) CacheManager.getCache().get(crmContactTypeKey);
    } else {// w ww. j  a v  a 2  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 CrmContactTypeData 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.
            crmContactTypeList.add(desc);

        } // closing for loop.

        CacheManager.getCache().put(crmContactTypeKey, crmContactTypeList);

        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 crmContactTypeList;// returning the object.
}

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

License:Open Source License

public List getGreensheetUnits(String greensheetUnitsKey) throws ServiceLocatorException {

    List greensheetUnitsList = new ArrayList();//Description

    if (CacheManager.getCache().containsKey(greensheetUnitsKey)) {
        greensheetUnitsList = (List) CacheManager.getCache().get(greensheetUnitsKey);
    } else {/* w w  w .j  a v  a 2s.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 GreensheetUnitsData 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.
            greensheetUnitsList.add(desc);

        } // closing for loop.

        CacheManager.getCache().put(greensheetUnitsKey, greensheetUnitsList);

        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 greensheetUnitsList;// returning the object.
}

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

License:Open Source License

public List getGreensheetVPSales(String greensheetVPSalesKey) throws ServiceLocatorException {

    List greensheetVPSalesList = new ArrayList();//Description

    if (CacheManager.getCache().containsKey(greensheetVPSalesKey)) {
        greensheetVPSalesList = (List) CacheManager.getCache().get(greensheetVPSalesKey);
    } else {/*from  w w w .  j ava  2s  . 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 GreensheetVPSalesData 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.
            greensheetVPSalesList.add(desc);

        } // closing for loop.

        CacheManager.getCache().put(greensheetVPSalesKey, greensheetVPSalesList);

        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 greensheetVPSalesList;// returning the object.
}

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

License:Open Source License

public List getGreenSheetExpenses(String greenSheetExpensesKey) throws ServiceLocatorException {

    List greenSheetExpensesList = new ArrayList();//key-Description

    if (CacheManager.getCache().containsKey(greenSheetExpensesKey)) {
        greenSheetExpensesList = (List) CacheManager.getCache().get(greenSheetExpensesKey);
    } else {/*w  w  w. j a  va 2s.  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 GreenSheetExpensesData 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.
            greenSheetExpensesList.add(desc);

        } // closing for loop.

        CacheManager.getCache().put(greenSheetExpensesKey, greenSheetExpensesList);

        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 greenSheetExpensesList;// returning the object.
}

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

License:Open Source License

public List getGreensheetCreationStatus(String greensheetCreationStatusKey) throws ServiceLocatorException {

    List greensheetCreationStatusList = new ArrayList();//Description

    if (CacheManager.getCache().containsKey(greensheetCreationStatusKey)) {
        greensheetCreationStatusList = (List) CacheManager.getCache().get(greensheetCreationStatusKey);
    } else {/* ww  w.  j a  va  2 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 GreensheetCreationStatusData 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.
            greensheetCreationStatusList.add(desc);

        } // closing for loop.

        CacheManager.getCache().put(greensheetCreationStatusKey, greensheetCreationStatusList);

        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 greensheetCreationStatusList;// returning the object.
}

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

License:Open Source License

public List getCrmActivityStatus(String crmActivityStatusKey) throws ServiceLocatorException {

    List crmActivityStatusList = new ArrayList();

    if (CacheManager.getCache().containsKey(crmActivityStatusKey)) {

        crmActivityStatusList = (List) CacheManager.getCache().get(crmActivityStatusKey);
    } else {/*from  ww w . j  ava  2 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 CrmActivityStatusData 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.
            crmActivityStatusList.add(desc);

        } // closing for loop.

        CacheManager.getCache().put(crmActivityStatusKey, crmActivityStatusList);

        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 crmActivityStatusList;// returning the object.
}

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

License:Open Source License

public List getPriority(String priorityKey) throws ServiceLocatorException {

    List priorityList = new ArrayList();

    if (CacheManager.getCache().containsKey(priorityKey)) {

        priorityList = (List) CacheManager.getCache().get(priorityKey);
    } else {/*from   w ww .  jav 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 PriorityData 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.
            priorityList.add(desc);

        } // closing for loop.

        CacheManager.getCache().put(priorityKey, priorityList);

        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 priorityList;// returning the object.
}

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

License:Open Source License

public List getRegion(String regionKey) throws ServiceLocatorException {

    List regionList = new ArrayList();

    if (CacheManager.getCache().containsKey(regionKey)) {

        regionList = (List) CacheManager.getCache().get(regionKey);
    } else {//www  . ja va 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 RegionData 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.
            regionList.add(desc);

        } // closing for loop.

        CacheManager.getCache().put(regionKey, regionList);

        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 regionList;// returning the object.
}

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

License:Open Source License

public Map getRegionMap(String regionKey) throws ServiceLocatorException {

    Map regionMap = null;/*  www.j  a va 2s.c o  m*/

    if (CacheManager.getCache().containsKey(regionKey)) {

        regionMap = (Map) CacheManager.getCache().get(regionKey);
    } else {
        //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.id,tp.description from RegionData as tp";
        Query query = session.createQuery(SQL_STG);
        for (Iterator it = query.iterate(); it.hasNext();) {
            Object[] row = (Object[]) it.next();
            //Storing values into the TreeMap.
            regionMap.put(row[0].toString(), row[1].toString());

        } // closing for loop.

        CacheManager.getCache().put(regionKey, regionMap);

        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 regionMap;// returning the object.
}