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 String getAccountName(int accountId) throws ServiceLocatorException { String accountName = null;// w w w. j av a 2s. co m Session session = HibernateServiceLocator.getInstance().getSession(); Transaction transaction = session.beginTransaction(); String SQL_QUERY = "Select tp.name from AccountData as tp where tp.id=:accountId"; Query query = session.createQuery(SQL_QUERY).setInteger("accountId", accountId); for (Iterator it = query.iterate(); it.hasNext();) { accountName = (String) it.next(); } //end of the for loop if (accountName == null) accountName = "Name is Null"; 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 accountName; }
From source file:com.mss.mirage.util.HibernateDataProvider.java
License:Open Source License
public int getAccountIdByContactId(int inContactId) throws ServiceLocatorException { int accountId = 0; Object accountIdObject = null; Session session = HibernateServiceLocator.getInstance().getSession(); Transaction transaction = session.beginTransaction(); String SQL_QUERY = "Select tp.accountId from ContactDataForAccountId as tp where tp.id=:contactId"; Query query = session.createQuery(SQL_QUERY).setInteger("contactId", inContactId); for (Iterator it = query.iterate(); it.hasNext();) { accountIdObject = (Object) it.next(); } //end of the for loop if (accountIdObject == null) accountIdObject = "0"; accountId = Integer.parseInt(accountIdObject.toString()); try {// w w w . ja v a 2s. c o m // 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 accountId; }
From source file:com.mss.mirage.util.HibernateDataProvider.java
License:Open Source License
public int getAccountIdByActivityId(int inActivityId) throws ServiceLocatorException { int accountId = 0; Object accountIdObject = null; Session session = HibernateServiceLocator.getInstance().getSession(); Transaction transaction = session.beginTransaction(); String SQL_QUERY = "Select tp.accountId from AccountIdForActivityId as tp where tp.id=:activityId"; Query query = session.createQuery(SQL_QUERY).setInteger("activityId", inActivityId); for (Iterator it = query.iterate(); it.hasNext();) { accountIdObject = (Object) it.next(); } //end of the for loop if (accountIdObject == null) accountIdObject = "0"; accountId = Integer.parseInt(accountIdObject.toString()); try {/*from w ww.j a va2 s. c o m*/ // 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 accountId; }
From source file:com.mss.mirage.util.HibernateDataProvider.java
License:Open Source License
public String getContactName(int inContactId) throws ServiceLocatorException { String contactName = null;/*from ww w. j a v a 2s. c om*/ Object fName = null; Object lName = null; Object mName = null; Session session = HibernateServiceLocator.getInstance().getSession(); Transaction transaction = session.beginTransaction(); String SQL_QUERY = "Select tp.firstName, tp.lastName,tp.middleName from ContactData as tp where tp.id=:contactId"; Query query = session.createQuery(SQL_QUERY).setInteger("contactId", inContactId); for (Iterator it = query.iterate(); it.hasNext();) { Object[] row = (Object[]) it.next(); fName = (Object) row[0]; lName = (Object) row[1]; mName = (Object) row[2]; } //end of the for loop if (fName == null) fName = ""; if (mName == null) mName = ""; if (lName == null) lName = ""; contactName = fName.toString() + " " + mName.toString() + "." + lName.toString(); 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 contactName; }
From source file:com.mss.mirage.util.HibernateDataProvider.java
License:Open Source License
public int getAccountIdByProjectId(int inProjectId) throws ServiceLocatorException { int accountId = 0; Object accountIdObject = null; Session session = HibernateServiceLocator.getInstance().getSession(); Transaction transaction = session.beginTransaction(); String SQL_QUERY = "Select tp.accountId from ProjectDataForAccountId as tp where tp.id=:projectId"; Query query = session.createQuery(SQL_QUERY).setInteger("projectId", inProjectId); for (Iterator it = query.iterate(); it.hasNext();) { accountIdObject = (Object) it.next(); } //end of the for loop if (accountIdObject == null) accountIdObject = "0"; accountId = Integer.parseInt(accountIdObject.toString()); try {/* w w w .ja v a2s .com*/ // 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 accountId; }
From source file:com.mss.mirage.util.HibernateDataProvider.java
License:Open Source License
public String getProjectName(int projectId) throws ServiceLocatorException { String projectName = null;//from w w w. java 2 s . c om Session session = HibernateServiceLocator.getInstance().getSession(); Transaction transaction = session.beginTransaction(); String SQL_QUERY = "Select tp.name from ProjectName as tp where tp.id=:projectId"; Query query = session.createQuery(SQL_QUERY).setInteger("projectId", projectId); for (Iterator it = query.iterate(); it.hasNext();) { projectName = (String) it.next(); } //end of the for loop if (projectName == null) projectName = "Name is Null"; 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 projectName; }
From source file:com.mss.mirage.util.HibernateDataProvider.java
License:Open Source License
public String getSubProjectName(int subProjectId) throws ServiceLocatorException { String subProjectName = null; Session session = HibernateServiceLocator.getInstance().getSession(); Transaction transaction = session.beginTransaction(); String SQL_QUERY = "Select tp.name from SubProjectName as tp where tp.id=:subProjectId"; Query query = session.createQuery(SQL_QUERY).setInteger("subProjectId", subProjectId); for (Iterator it = query.iterate(); it.hasNext();) { subProjectName = (String) it.next(); } //end of the for loop if (subProjectName == null) subProjectName = "Name is Null"; try {/*from ww w . j a v a2s.com*/ // 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 subProjectName; }
From source file:com.mss.mirage.util.HibernateDataProvider.java
License:Open Source License
public String getMapName(int mapId) throws ServiceLocatorException { String mapName = null;/*from w w w . j a v a2 s. c om*/ Session session = HibernateServiceLocator.getInstance().getSession(); Transaction transaction = session.beginTransaction(); String SQL_QUERY = "Select tp.name from MapName as tp where tp.id=:mapId"; Query query = session.createQuery(SQL_QUERY).setInteger("mapId", mapId); for (Iterator it = query.iterate(); it.hasNext();) { mapName = (String) it.next(); } //end of the for loop if (mapName == null) mapName = "Name is Null"; 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 mapName; }
From source file:com.mss.mirage.util.HibernateDataProvider.java
License:Open Source License
public String getMapIssueType(int issueId) throws ServiceLocatorException { String mapIssueType = null;/*from w w w . j av a 2 s. co m*/ Session session = HibernateServiceLocator.getInstance().getSession(); Transaction transaction = session.beginTransaction(); String SQL_QUERY = "Select tp.name from MapIssueType as tp where tp.id=:issueId"; Query query = session.createQuery(SQL_QUERY).setInteger("issueId", issueId); for (Iterator it = query.iterate(); it.hasNext();) { mapIssueType = (String) it.next(); } //end of the for loop if (mapIssueType == null) mapIssueType = "Name is Null"; 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 mapIssueType; }
From source file:com.mss.mirage.util.HibernateDataProvider.java
License:Open Source License
public int getContactIdByActivityId(int inActivityId) throws ServiceLocatorException { int inContactId = 0; Object contactIdObject = null; Session session = HibernateServiceLocator.getInstance().getSession(); Transaction transaction = session.beginTransaction(); String SQL_QUERY = "Select tp.contactId from CrmActivityDataForContactId as tp where tp.id=:activityId"; Query query = session.createQuery(SQL_QUERY).setInteger("activityId", inActivityId); for (Iterator it = query.iterate(); it.hasNext();) { contactIdObject = (Object) it.next(); } //end of the for loop if (contactIdObject == null) contactIdObject = "0"; inContactId = Integer.parseInt(contactIdObject.toString()); try {/*w w w. j a va 2 s. c om*/ // 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 inContactId; }