Example usage for org.hibernate Query setParameter

List of usage examples for org.hibernate Query setParameter

Introduction

In this page you can find the example usage for org.hibernate Query setParameter.

Prototype

@SuppressWarnings("unchecked")
Query<R> setParameter(int position, Object val);

Source Link

Document

Bind a positional query parameter using its inferred Type.

Usage

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)//from w  ww.  jav a2 s  .  c  o  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();
}

From source file:au.org.theark.core.dao.StudyDao.java

License:Open Source License

public Collection<ConsentStatusField> getSelectedConsentStatusFieldsForSearch(Search search) {
    String queryString = "select csfs.consentStatusField" + " from ConsentStatusFieldSearch csfs "
            + " where csfs.search=:search " + " order by csfs.consentStatusField.entity ";
    Query query = getSession().createQuery(queryString);
    query.setParameter("search", search);
    log.info("QueryString: " + query.getQueryString());
    log.info("getselectedconsentstatusfieldforsearch results:");
    for (ConsentStatusField c : (List<ConsentStatusField>) query.list()) {
        log.info(c.getPublicFieldName());
    }//from  w ww. j ava2  s  .c  om
    return query.list();
}

From source file:au.org.theark.core.dao.StudyDao.java

License:Open Source License

public List<ConsentStatusField> getSelectedConsentStatusFieldsForSearch(Search search,
        Entity entityEnumToRestrictOn) {
    String queryString = "select csfs.consentStatusField from ConsentStatusFieldSearch csfs where csfs.search=:search "
            + " and csfs.consentStatusField.entity=:entityEnumToRestrictOn ";
    Query query = getSession().createQuery(queryString);
    query.setParameter("search", search);
    query.setParameter("entityEnumToRestrictOn", entityEnumToRestrictOn);
    return query.list();
}

From source file:au.org.theark.core.dao.StudyDao.java

License:Open Source License

public List<DemographicField> getSelectedDemographicFieldsForSearch(Search search) {
    String queryString = "select dfs.demographicField " + " from DemographicFieldSearch dfs "
            + " where dfs.search=:search " + " order by dfs.demographicField.entity ";
    Query query = getSession().createQuery(queryString);
    query.setParameter("search", search);
    return query.list();
}

From source file:au.org.theark.core.dao.StudyDao.java

License:Open Source License

public List<DemographicField> getSelectedDemographicFieldsForSearch(Search search,
        Entity entityEnumToRestrictOn) {
    String queryString = "select dfs.demographicField from DemographicFieldSearch dfs where dfs.search=:search "
            + " and dfs.demographicField.entity=:entityEnumToRestrictOn ";
    Query query = getSession().createQuery(queryString);
    query.setParameter("search", search);
    query.setParameter("entityEnumToRestrictOn", entityEnumToRestrictOn);
    return query.list();
}

From source file:au.org.theark.core.dao.StudyDao.java

License:Open Source License

public List<BiospecimenField> getSelectedBiospecimenFieldsForSearch(Search search) {
    String queryString = "select bsfs.biospecimenField from BiospecimenFieldSearch bsfs "
            + " where bsfs.search=:search ";
    Query query = getSession().createQuery(queryString);
    query.setParameter("search", search);
    return query.list();
}

From source file:au.org.theark.core.dao.StudyDao.java

License:Open Source License

public List<BiocollectionField> getSelectedBiocollectionFieldsForSearch(Search search) {
    String queryString = "select bcfs.biocollectionField " + " from BiocollectionFieldSearch bcfs "
            + " where bcfs.search=:search ";
    Query query = getSession().createQuery(queryString);
    query.setParameter("search", search);
    return query.list();
}