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

/**
 *@ returns List for Countries.//from  w ww  .ja v  a 2s.  c  o m
 *@ throws HibernateException.
 */
public List getStatesList(String statesKey) throws ServiceLocatorException {

    List statesList = new ArrayList();

    if (CacheManager.getCache().containsKey(statesKey)) {
        statesList = (List) CacheManager.getCache().get(statesKey);

    } else {

        //getting hibernate session from the HibernateServiceLocator 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 StatesData 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.
            statesList.add(desc);

        } // closing for loop.

        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);
                }
            }
        }
    }
    return statesList; // returning the object.
}

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

License:Open Source License

public Map getCrmBDM(String BDMKey) throws ServiceLocatorException {

    Map crmBDMMap = new TreeMap();//key-Description

    if (CacheManager.getCache().containsKey(BDMKey)) {
        crmBDMMap = (Map) CacheManager.getCache().get(BDMKey);
    } else {//from  w  w  w  .  jav a 2  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.bdmID,tp.description from CrmBDMData 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.
            crmBDMMap.put(row[0].toString(), row[1].toString());

        } // closing for loop.

        CacheManager.getCache().put(BDMKey, crmBDMMap);

        // Closing hibernate session
        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 crmBDMMap;// returning the object.
}

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

License:Open Source License

public Map getGreenSheetUnits(String greenSheetUntiskey) throws ServiceLocatorException {

    Map greenSheetUntisMap = new TreeMap();

    if (CacheManager.getCache().containsKey(greenSheetUntiskey)) {
        greenSheetUntisMap = (Map) CacheManager.getCache().get(greenSheetUntiskey);
    } else {/*from   w ww  . j  a  v  a2  s  .  c o m*/
        //getting sessionFactory for the HibernateUtil class.
        Session session = HibernateServiceLocator.getInstance().getSession();

        //Genarating a quary for retrieving the data from the database.
        String SQL_STG = "select tp.bdmID,tp.description from CrmGreenSheetUnitsData 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.
            greenSheetUntisMap.put(row[0].toString(), row[1].toString());

        } // closing for loop.

        CacheManager.getCache().put(greenSheetUntiskey, greenSheetUntisMap);

        // Closing hibernate session
        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 greenSheetUntisMap;// returning the object.
}

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

License:Open Source License

public List getGreenSheetExpences(String greenSheetExpenceskey) throws ServiceLocatorException {

    List greenSheetExpencesList = new ArrayList();//Description

    if (CacheManager.getCache().containsKey(greenSheetExpenceskey)) {
        greenSheetExpencesList = (List) CacheManager.getCache().get(greenSheetExpenceskey);
    } else {/*  w w  w. j av  a  2  s .  c  o  m*/
        //getting sessionFactory for the HibernateUtil class.
        Session session = HibernateServiceLocator.getInstance().getSession();

        //Genarating a quary for retrieving the data from the database.
        String SQL_STG = "select tp.description from CrmGreenSheetExpencesData as tp";
        Query query = session.createQuery(SQL_STG);
        for (Iterator it = query.iterate(); it.hasNext();) {
            String desc = (String) it.next();
            greenSheetExpencesList.add(desc);

        } // closing for loop.

        CacheManager.getCache().put(greenSheetExpenceskey, greenSheetExpencesList);

        // Closing hibernate session
        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 greenSheetExpencesList;// returning the object.
}

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

License:Open Source License

public Map getGreenSheetClientBillingRate(String greenSheetCurrencykey) throws ServiceLocatorException {

    Map greenSheetCurrencyMap = new TreeMap();//key-Description

    if (CacheManager.getCache().containsKey(greenSheetCurrencykey)) {
        greenSheetCurrencyMap = (Map) CacheManager.getCache().get(greenSheetCurrencykey);
    } else {//w ww  . ja v  a  2s . c  o  m
        //getting sessionFactory for the HibernateUtil class.
        Session session = HibernateServiceLocator.getInstance().getSession();

        //Genarating a quary for retrieving the data from the database.
        String SQL_STG = "select tp.bdmID,tp.description from CrmGreenSheetCurrencyData 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.
            greenSheetCurrencyMap.put(row[0].toString(), row[1].toString());

        } // closing for loop.

        CacheManager.getCache().put(greenSheetCurrencykey, greenSheetCurrencyMap);
        session.clear();
        // Closing hibernate session
        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 greenSheetCurrencyMap;// returning the object.
}

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

License:Open Source License

public List getGreenSheetStatus(String greenSheetStatuskey) throws ServiceLocatorException {

    List greenSheetStatusMap = new ArrayList();//Description

    if (CacheManager.getCache().containsKey(greenSheetStatuskey)) {
        greenSheetStatusMap = (List) CacheManager.getCache().get(greenSheetStatuskey);
    } else {/*from w  ww .ja  v  a 2  s .c  om*/
        //getting sessionFactory for the HibernateUtil class.
        Session session = HibernateServiceLocator.getInstance().getSession();

        //Genarating a quary for retrieving the data from the database.
        String SQL_STG = "select tp.description from CrmGreenSheetStatusData as tp";
        Query query = session.createQuery(SQL_STG);
        for (Iterator it = query.iterate(); it.hasNext();) {
            String desc = (String) it.next();
            //Storing values into the TreeMap.
            greenSheetStatusMap.add(desc);

        } // closing for loop.

        CacheManager.getCache().put(greenSheetStatuskey, greenSheetStatusMap);
        session.clear();
        // Closing hibernate session
        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 greenSheetStatusMap;// returning the object.
}

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

License:Open Source License

public List getGreenSheetPOStatus(String greenSheetPOStatuskey) throws ServiceLocatorException {

    List greenSheetPOStautsMap = new ArrayList();//Description

    if (CacheManager.getCache().containsKey(greenSheetPOStatuskey)) {
        greenSheetPOStautsMap = (List) CacheManager.getCache().get(greenSheetPOStatuskey);
    } else {// w w w  .  j a  va  2 s .c o m
        //getting sessionFactory for the HibernateUtil class.
        Session session = HibernateServiceLocator.getInstance().getSession();

        //Genarating a quary for retrieving the data from the database.
        String SQL_STG = "select tp.description from CrmGreenSheetPOStatusData as tp";
        Query query = session.createQuery(SQL_STG);
        for (Iterator it = query.iterate(); it.hasNext();) {
            String desc = (String) it.next();
            //Storing values into the TreeMap.
            greenSheetPOStautsMap.add(desc);

        } // closing for loop.

        CacheManager.getCache().put(greenSheetPOStatuskey, greenSheetPOStautsMap);
        session.clear();
        // Closing hibernate session
        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 greenSheetPOStautsMap;// returning the object.
}

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

License:Open Source License

public Map getGreenSheetScopeOfWorkList(String greenSheetScopeOfWorkkey) throws ServiceLocatorException {

    Map greenSheetScopeOfWork = new TreeMap();//key-Description

    if (CacheManager.getCache().containsKey(greenSheetScopeOfWorkkey)) {
        greenSheetScopeOfWork = (Map) CacheManager.getCache().get(greenSheetScopeOfWorkkey);
    } else {/*from   w ww.  j  a va  2  s  . c  o m*/
        //getting sessionFactory for the HibernateUtil class.
        Session session = HibernateServiceLocator.getInstance().getSession();

        //Genarating a quary for retrieving the data from the database.
        String SQL_STG = "select tp.bdmID,tp.description from CrmGreenSheetScopeOfWorkData 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.
            greenSheetScopeOfWork.put(row[0].toString(), row[1].toString());

        } // closing for loop.

        CacheManager.getCache().put(greenSheetScopeOfWorkkey, greenSheetScopeOfWork);

        session.clear();
        // Closing hibernate session
        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 greenSheetScopeOfWork;// returning the object.
}

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

License:Open Source License

public List getGreenSheetVPSalesList(String greenSheetVPSaleskey) throws ServiceLocatorException {

    List greenSheetVPSalesList = new ArrayList();//Description

    if (CacheManager.getCache().containsKey(greenSheetVPSaleskey)) {
        greenSheetVPSalesList = (List) CacheManager.getCache().get(greenSheetVPSaleskey);
    } else {//from   www  . java  2s. co  m
        //getting sessionFactory for the HibernateUtil class.
        Session session = HibernateServiceLocator.getInstance().getSession();

        //Genarating a quary for retrieving the data from the database.
        String SQL_STG = "select tp.description from CrmGreenSheetVPSalesData as tp";
        Query query = session.createQuery(SQL_STG);
        for (Iterator it = query.iterate(); it.hasNext();) {
            String desc = (String) it.next();
            //Storing values into the TreeMap.
            greenSheetVPSalesList.add(desc);
        } // closing for loop.

        CacheManager.getCache().put(greenSheetVPSaleskey, greenSheetVPSalesList);

        session.clear();
        // Closing hibernate session
        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 Map getGreenSheetPaymentTerms(String greenSheetPaymentTermskey) throws ServiceLocatorException {

    Map greenSheetPaymentTermsMap = new TreeMap();//key-Description

    if (CacheManager.getCache().containsKey(greenSheetPaymentTermskey)) {
        greenSheetPaymentTermsMap = (Map) CacheManager.getCache().get(greenSheetPaymentTermskey);
    } else {//from w w w .j  a v  a  2  s  .com
        //getting sessionFactory for the HibernateUtil class.
        Session session = HibernateServiceLocator.getInstance().getSession();

        //Genarating a quary for retrieving the data from the database.
        String SQL_STG = "select tp.bdmID,tp.description from CrmGreenSheetPaymentTermsData 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.
            greenSheetPaymentTermsMap.put(row[0].toString(), row[1].toString());

        } // closing for loop.

        session.clear();
        CacheManager.getCache().put(greenSheetPaymentTermskey, greenSheetPaymentTermsMap);

        // Closing hibernate session
        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 greenSheetPaymentTermsMap;// returning the object.
}