List of usage examples for org.hibernate Query iterate
Iterator<R> iterate();
From source file:com.mss.mirage.util.HibernateDataProvider.java
License:Open Source License
public List getTerritoryList(String qsterritorylist) throws ServiceLocatorException { if (CacheManager.getCache().containsKey(qsterritorylist)) { territoryList = (List) CacheManager.getCache().get(qsterritorylist); //returning sigleton object. } else {//from ww w. j av a2 s. c om //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 TerritoryData 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. territoryList.add(desc); } // closing for loop. CacheManager.getCache().put(qsterritorylist, territoryList); try { // Closing hibernate session session.close(); session = null; query = null; } catch (HibernateException he) { he.printStackTrace(); } finally { if (session != null) { try { session.close(); session = null; } catch (HibernateException he) { throw new ServiceLocatorException(he); } } } } // closing if condition. return territoryList; }
From source file:com.mss.mirage.util.HibernateDataProvider.java
License:Open Source License
public List getDefaultStatesList(int CountryCode) throws ServiceLocatorException { String defaultStatesKey = "defaultStates"; List statesList = new ArrayList(); if (CacheManager.getCache().containsKey(defaultStatesKey)) { statesList = (List) CacheManager.getCache().get(defaultStatesKey); } else {/*from ww w .ja va 2s .c om*/ //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 DefaultStatesData AS tp where tp.countryId=:country"; Query query = session.createQuery(SQL_STG).setInteger("country", CountryCode); 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 List getEmpActivities(String empActivityKey) throws ServiceLocatorException { List empActivityTypesList = new ArrayList();//Description if (CacheManager.getCache().containsKey(empActivityKey)) { empActivityTypesList = (List) CacheManager.getCache().get(empActivityKey); } else {/*from w ww.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 EmpActivityData 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. empActivityTypesList.add(desc); } // closing for loop. CacheManager.getCache().put(empActivityKey, empActivityTypesList); 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 empActivityTypesList;// returning the object. }
From source file:com.mss.mirage.util.HibernateDataProvider.java
License:Open Source License
public List getProjectType(String projectTypeKey) throws ServiceLocatorException { List projectTypeList = new ArrayList();//Description if (CacheManager.getCache().containsKey(projectTypeKey)) { projectTypeList = (List) CacheManager.getCache().get(projectTypeKey); } else {// www . jav a 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 ProjectTypeData 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. projectTypeList.add(desc); } // closing for loop. CacheManager.getCache().put(projectTypeKey, projectTypeList); 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(projectTypeList); return projectTypeList;// returning the object. }
From source file:com.mss.mirage.util.HibernateDataProvider.java
License:Open Source License
public List getProjectStatusType(String projectStatusTypeKey) throws ServiceLocatorException { List projectStatusTypeList = new ArrayList();//Description if (CacheManager.getCache().containsKey(projectStatusTypeKey)) { projectStatusTypeList = (List) CacheManager.getCache().get(projectStatusTypeKey); } else {//from w w w.java 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 ProjectStatusTypeData 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. projectStatusTypeList.add(desc); } // closing for loop. CacheManager.getCache().put(projectStatusTypeKey, projectStatusTypeList); 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 projectStatusTypeList;// returning the object. }
From source file:com.mss.mirage.util.HibernateDataProvider.java
License:Open Source License
public List getTime(String timeKey) throws ServiceLocatorException { List timeTypeList = new ArrayList();//Description if (CacheManager.getCache().containsKey(timeKey)) { timeTypeList = (List) CacheManager.getCache().get(timeKey); } else {/*w ww . j av 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 TimeData 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. timeTypeList.add(desc); } // closing for loop. CacheManager.getCache().put(timeKey, timeTypeList); 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 timeTypeList;// returning the object. }
From source file:com.mss.mirage.util.HibernateDataProvider.java
License:Open Source License
public List getTimeSheetStatus(String timeSheetStatusKey) throws ServiceLocatorException { List timeSheetStatusTypesList = new ArrayList();//Description if (CacheManager.getCache().containsKey(timeSheetStatusKey)) { timeSheetStatusTypesList = (List) CacheManager.getCache().get(timeSheetStatusKey); } else {//from www . jav 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 TimeSheetStatusData 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. timeSheetStatusTypesList.add(desc); } // closing for loop. CacheManager.getCache().put(timeSheetStatusKey, timeSheetStatusTypesList); 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 timeSheetStatusTypesList;// returning the object. }
From source file:com.mss.mirage.util.HibernateDataProvider.java
License:Open Source License
public List getLkOrganization(String lKOrganizationKey) throws ServiceLocatorException { List lKOrganizationList = new ArrayList();//Description if (CacheManager.getCache().containsKey(lKOrganizationKey)) { lKOrganizationList = (List) CacheManager.getCache().get(lKOrganizationKey); } else {/*from w w w. j av 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 LKOrganizationData 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. lKOrganizationList.add(desc); } // closing for loop. CacheManager.getCache().put(lKOrganizationKey, lKOrganizationList); 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 lKOrganizationList;// returning the object. }
From source file:com.mss.mirage.util.HibernateDataProvider.java
License:Open Source License
public List getDepartment(String lKDepartmentKey) throws ServiceLocatorException { List lKDepartmentList = new ArrayList(); if (CacheManager.getCache().containsKey(lKDepartmentKey)) { lKDepartmentList = (List) CacheManager.getCache().get(lKDepartmentKey); } else {// ww w .j a va2s. 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 LKDepartmentData 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. lKDepartmentList.add(desc); } // closing for loop. CacheManager.getCache().put(lKDepartmentKey, lKDepartmentList); 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 lKDepartmentList;// returning the object. }
From source file:com.mss.mirage.util.HibernateDataProvider.java
License:Open Source License
public List getPractice(String lKPracticeKey) throws ServiceLocatorException { List lKPracticeList = new ArrayList();//Description if (CacheManager.getCache().containsKey(lKPracticeKey)) { lKPracticeList = (List) CacheManager.getCache().get(lKPracticeKey); } else {/*from www . j a v a 2 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 LKPracticeData 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. lKPracticeList.add(desc); } // closing for loop. CacheManager.getCache().put(lKPracticeKey, lKPracticeList); 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 lKPracticeList;// returning the object. }