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 Map getModuleNames(String moduleKey) throws ServiceLocatorException { Map moduleMap = new TreeMap();// Key-Description if (CacheManager.getCache().containsKey(moduleKey)) { moduleMap = (Map) CacheManager.getCache().get(moduleKey); } else {//from w w 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.id,tp.description from ModuleData 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. moduleMap.put(row[0].toString(), row[1].toString()); } // closing for loop. //Storing the rolesMap object in to the cache as singleton object. CacheManager.getCache().put(moduleKey, moduleMap); // 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 moduleMap; // returning the object. }
From source file:com.mss.mirage.util.HibernateDataProvider.java
License:Open Source License
public List getIssueCategories(String issueKey) throws ServiceLocatorException { List issueCategoryList = new ArrayList(); if (CacheManager.getCache().containsKey(issueKey)) { issueCategoryList = (List) CacheManager.getCache().get(issueKey); } else {/*from w w w. ja v a2 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 IssuesCategoryData as tp"; Query query = session.createQuery(SQL_STG); for (Iterator it = query.iterate(); it.hasNext();) { String row = (String) it.next(); //Storing values into the TreeMap. issueCategoryList.add(row); } // closing for loop. //Storing the IssueCategory object in to the cache as singleton object. CacheManager.getCache().put(issueKey, issueCategoryList); // 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 issueCategoryList; // returning the object. }
From source file:com.mss.mirage.util.HibernateDataProvider.java
License:Open Source License
public List getIssueStatus(String issueStatusKey) throws ServiceLocatorException { List issueStatusList = new ArrayList(); if (CacheManager.getCache().containsKey(issueStatusKey)) { issueStatusList = (List) CacheManager.getCache().get(issueStatusKey); } else {/* ww 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 IssueStatusData as tp"; Query query = session.createQuery(SQL_STG); for (Iterator it = query.iterate(); it.hasNext();) { String row = (String) it.next(); //Storing values into the ArrayList. issueStatusList.add(row); } // closing for loop. //Storing the issueStatusMap object in to the cache as singleton object. CacheManager.getCache().put(issueStatusKey, issueStatusList); // 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 issueStatusList; // returning the object. }
From source file:com.mss.mirage.util.HibernateDataProvider.java
License:Open Source License
public List getEmpReportsType(String employeReportsKey) throws ServiceLocatorException { List empreportsTypeList = new ArrayList(); if (CacheManager.getCache().containsKey(employeReportsKey)) { empreportsTypeList = (List) CacheManager.getCache().get(employeReportsKey); } else {// w ww . ja 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 LKEmpRepType 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. empreportsTypeList.add(desc); } // closing for loop. CacheManager.getCache().put(employeReportsKey, empreportsTypeList); 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 empreportsTypeList;// returning the object. }
From source file:com.mss.mirage.util.HibernateDataProvider.java
License:Open Source License
public List getImmigrationStatus(String immigrationStatusKey) throws ServiceLocatorException { List immigrationStatusTypesList = new ArrayList();//Description if (CacheManager.getCache().containsKey(immigrationStatusKey)) { immigrationStatusTypesList = (List) CacheManager.getCache().get(immigrationStatusKey); } else {/*from w w w . j a va 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 ImmigrationData 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. immigrationStatusTypesList.add(desc); } // closing for loop. CacheManager.getCache().put(immigrationStatusKey, immigrationStatusTypesList); 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 immigrationStatusTypesList;// returning the object. }
From source file:com.mss.mirage.util.HibernateDataProvider.java
License:Open Source License
public List getHealthInsuranceType(String empHealthInsuranceKey) throws ServiceLocatorException { List empHealthInsuranceTypesList = new ArrayList();//Description if (CacheManager.getCache().containsKey(empHealthInsuranceKey)) { empHealthInsuranceTypesList = (List) CacheManager.getCache().get(empHealthInsuranceKey); } else {//from w w w . 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 EmpHealthInsuranceData 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. empHealthInsuranceTypesList.add(desc); } // closing for loop. CacheManager.getCache().put(empHealthInsuranceKey, empHealthInsuranceTypesList); 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 empHealthInsuranceTypesList;// returning the object. }
From source file:com.mss.mirage.util.HibernateDataProvider.java
License:Open Source License
public String getIssueName(int issueId) throws ServiceLocatorException { String issuesName = null;/* ww w . j a va 2s .c o m*/ Session session = HibernateServiceLocator.getInstance().getSession(); Transaction transaction = session.beginTransaction(); String SQL_QUERY = "Select tp.name from IssueData as tp where tp.id=:issueId"; Query query = session.createQuery(SQL_QUERY).setInteger("issueId", issueId); for (Iterator it = query.iterate(); it.hasNext();) { issuesName = (String) it.next(); } //end of the for loop if (issuesName == null) issuesName = "Name is Null"; try { // Closing hibernate session session.close(); session = null; } catch (HibernateException he) { he.printStackTrace(); } finally { if (session != null) { try { session.close(); session = null; } catch (HibernateException he) { he.printStackTrace(); } } } return issuesName; }
From source file:com.mss.mirage.util.HibernateDataProvider.java
License:Open Source License
public List getmarsProjects(String projectKey) throws ServiceLocatorException { List project = new ArrayList(); if (CacheManager.getCache().containsKey(projectKey)) { project = (List) CacheManager.getCache().get(projectKey); //returning sigleton object. } else {//from w ww .j av a 2s . com //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 ProjectData 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. project.add(desc); } // closing for loop. CacheManager.getCache().put(projectKey, project); try { // Closing hibernate session session.close(); session = null; } catch (HibernateException he) { he.printStackTrace(); } finally { if (session != null) { try { session.close(); session = null; } catch (HibernateException he) { he.printStackTrace(); } } } } // closing if condition. return project; // returning the object. }
From source file:com.mss.mirage.util.HibernateDataProvider.java
License:Open Source License
public List getSubProjectsMap(String SubProjectKey) throws ServiceLocatorException { List subProjectMap = new ArrayList(); if (CacheManager.getCache().containsKey(SubProjectKey)) { subProjectMap = (List) CacheManager.getCache().get(SubProjectKey); //returning sigleton object. } else {/*from w w w. j ava 2 s.c o m*/ //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 SubProjectData 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. subProjectMap.add(desc); } // closing for loop. CacheManager.getCache().put(SubProjectKey, subProjectMap); try { // Closing hibernate session session.close(); session = null; } catch (HibernateException he) { he.printStackTrace(); } finally { if (session != null) { try { session.close(); session = null; } catch (HibernateException he) { he.printStackTrace(); } } } } // closing if condition. return subProjectMap; // returning the object. }
From source file:com.mss.mirage.util.HibernateDataProvider.java
License:Open Source License
public List getToolsMap(String toolKey) throws ServiceLocatorException { List toolListMap = new ArrayList(); if (CacheManager.getCache().containsKey(toolKey)) { toolListMap = (List) CacheManager.getCache().get(toolKey); //returning sigleton object. } else {/*w ww . ja v a2s . co m*/ //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 ToolData 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. toolListMap.add(desc); } // closing for loop. CacheManager.getCache().put(toolKey, toolListMap); try { // Closing hibernate session session.close(); session = null; } catch (HibernateException he) { he.printStackTrace(); } finally { if (session != null) { try { session.close(); session = null; } catch (HibernateException he) { he.printStackTrace(); } } } } // closing if condition. return toolListMap; // returning the object. }