List of usage examples for org.hibernate Query list
List<R> list();
From source file:au.edu.anu.metadatastores.store.search.SearchService.java
License:Open Source License
/** * Get the system types (i.e. the types for Publications, Grants, People, etc.) * //from www . ja v a 2 s. com * @return The system types */ public List<SystemType> getSystemTypes() { Session session = StoreHibernateUtil.getSessionFactory().openSession(); try { Query query = session.createQuery("FROM SystemType"); @SuppressWarnings("unchecked") List<SystemType> systemTypes = query.list(); return systemTypes; } finally { session.close(); } }
From source file:au.edu.anu.metadatastores.store.search.SearchService.java
License:Open Source License
/** * Get the attribute types (i.e. the types for Title, Given Name, Year, etc.) * /*from w w w. j a va 2 s.co m*/ * @return The attribute types */ public List<AttributeType> getAttributeTypes() { Session session = StoreHibernateUtil.getSessionFactory().openSession(); try { Query query = session.createQuery("FROM AttributeType"); @SuppressWarnings("unchecked") List<AttributeType> attributeTypes = query.list(); return attributeTypes; } finally { session.close(); } }
From source file:au.edu.anu.metadatastores.store.search.SearchService.java
License:Open Source License
/** * Execute the relationship query/*from ww w . j av a 2s .c o m*/ * * @param session The hibernate session * @param queryString The query string * @param id The id of the object * @param system The system to filter the relation on if it exists * @return The related items */ private List<ItemDTO> executeRelationQuery(Session session, String queryString, Long id, String system) { Query query = session.createQuery(queryString.toString()); query.setParameter("id", id); if (system != null && system.length() > 0) { query.setParameter("system", system); } @SuppressWarnings("unchecked") List<ItemDTO> items = query.list(); return items; }
From source file:au.org.theark.core.dao.ArkAuthorisationDao.java
License:Open Source License
/** * List of ArkRolePolicyTemplates for users other than the super Admin. * // w w w.j a v a 2 s .c om * Here I was failed to use the projection list because I need the whole "ArkRolePolicyTemplate" object list * So I used instead of a query for that. * * Group by function. */ @SuppressWarnings("unchecked") public List<ArkRolePolicyTemplate> getArkRolePolicytemplateList(ArkUserRole arkUserRole) { String queryString = "SELECT arpt FROM ArkRolePolicyTemplate arpt where arpt.arkRole=(:arkRole) and " + "arpt.arkModule=(:arkModule) group by arpt.arkFunction, arpt.id"; Query query = getSession().createQuery(queryString); query.setParameter("arkRole", arkUserRole.getArkRole()); query.setParameter("arkModule", arkUserRole.getArkModule()); List<ArkRolePolicyTemplate> arkRolePolicyTemplateLst = query.list(); return arkRolePolicyTemplateLst; }
From source file:au.org.theark.core.dao.StudyDao.java
License:Open Source License
public List<String> getSubjectUIDsThatAlreadyExistWithTheseUIDs(Study study, Collection<String> subjectUids) { String queryString = "select subject.subjectUID " + "from LinkSubjectStudy subject " + "where study =:study " + "and subjectUID in (:subjects) "; Query query = getSession().createQuery(queryString); query.setParameter("study", study); query.setParameterList("subjects", subjectUids); return query.list(); }
From source file:au.org.theark.core.dao.StudyDao.java
License:Open Source License
/** * based on sql concept of;4 select id from custom_field_display where custom_field_id in (SELECT id FROM custom_field where name='AGE' and * study_id = 1 and ark_function_id = 5) * //from w w w .j a va 2 s .com * @param fieldNameCollection * @param study * @return */ @SuppressWarnings("unchecked") public List<CustomFieldDisplay> getCustomFieldDisplaysIn(List<String> fieldNameCollection, Study study, ArkFunction arkFunction) { if (fieldNameCollection == null || fieldNameCollection.isEmpty()) { return new ArrayList<CustomFieldDisplay>(); } else { List<String> lowerCaseNames = new ArrayList<String>(); for (String name : fieldNameCollection) { lowerCaseNames.add(name.toLowerCase()); } String queryString = "select cfd " + "from CustomFieldDisplay cfd " + "where customField.id in ( " + " SELECT id from CustomField cf " + " where cf.study =:study " + " and lower(cf.name) in (:names) " + " and cf.arkFunction =:arkFunction )"; Query query = getSession().createQuery(queryString); query.setParameter("study", study); // query.setParameterList("names", fieldNameCollection); query.setParameterList("names", lowerCaseNames); query.setParameter("arkFunction", arkFunction); return query.list(); } }
From source file:au.org.theark.core.dao.StudyDao.java
License:Open Source License
@SuppressWarnings("unchecked") public List<CustomFieldDisplay> getCustomFieldDisplaysIn(Study study, ArkFunction arkFunction) { String queryString = "select cfd " + " from CustomFieldDisplay cfd " + " where customField.id in ( " + " SELECT id from CustomField cf " + " where cf.study =:study " + " and cf.arkFunction =:arkFunction )"; Query query = getSession().createQuery(queryString); query.setParameter("study", study); query.setParameter("arkFunction", arkFunction); return query.list(); }
From source file:au.org.theark.core.dao.StudyDao.java
License:Open Source License
public List<PhenoDataSetFieldDisplay> getPhenoFieldDisplaysIn(Study study, ArkFunction arkFunction) { String queryString = "select pdsfd from PhenoDataSetFieldDisplay pdsfd " + " where phenoDataSetField.id in ( " + " SELECT id from PhenoDataSetField pdsf " + " where pdsf.study =:study " + " and pdsf.arkFunction =:arkFunction )"; Query query = getSession().createQuery(queryString); query.setParameter("study", study); query.setParameter("arkFunction", arkFunction); return query.list(); }
From source file:au.org.theark.core.dao.StudyDao.java
License:Open Source License
/** * based on sql concept of; select id from custom_field_display where custom_field_id in (SELECT id FROM custom_field where name='AGE' and study_id * = 1 and ark_function_id = 5)/* w w w . j a v a 2 s .co m*/ * * @param fieldNameCollection * @param study * @return */ /*@SuppressWarnings("unchecked") public List<CustomFieldDisplay> getCustomFieldDisplaysIn(List<String> fieldNameCollection, Study study, ArkFunction arkFunction, CustomFieldGroup customFieldGroup) { if (fieldNameCollection == null || fieldNameCollection.isEmpty()) { return new ArrayList<CustomFieldDisplay>(); } else { List<String> lowerCaseNames = new ArrayList<String>(); for (String name : fieldNameCollection) { lowerCaseNames.add(name.toLowerCase()); } String queryString = "select cfd from CustomFieldDisplay cfd " + " where cfd.customFieldGroup =:customFieldGroup and customField.id in ( " + " SELECT id from CustomField cf " + " where cf.study =:study " + " and lower(cf.name) in (:names) " + " and cf.arkFunction =:arkFunction )"; Query query = getSession().createQuery(queryString); query.setParameter("study", study); // query.setParameterList("names", fieldNameCollection); query.setParameterList("names", lowerCaseNames); query.setParameter("arkFunction", arkFunction); query.setParameter("customFieldGroup", customFieldGroup); return query.list(); } }*/ @SuppressWarnings("unchecked") public List<LinkSubjectStudy> getSubjectsThatAlreadyExistWithTheseUIDs(Study study, Collection subjectUids) { String queryString = "select subject " + "from LinkSubjectStudy subject " + "where study =:study " + "and subjectUID in (:subjects) "; Query query = getSession().createQuery(queryString); query.setParameter("study", study); query.setParameterList("subjects", subjectUids); return query.list(); }
From source file:au.org.theark.core.dao.StudyDao.java
License:Open Source License
@SuppressWarnings("unchecked") public List<String> getAllSubjectUIDs(Study study) { String queryString = "select subject.subjectUID " + "from LinkSubjectStudy subject " + "where study =:study " + "order by subjectUID "; Query query = getSession().createQuery(queryString); query.setParameter("study", study); return query.list(); }