List of usage examples for org.hibernate SQLQuery setParameterList
@Override NativeQuery<T> setParameterList(String name, Object[] values);
From source file:org.generationcp.middleware.dao.gdms.AccMetadataSetDAO.java
License:Open Source License
@SuppressWarnings("rawtypes") //FIXME//from w w w . j ava 2 s . c o m public List<AccMetadataSet> getAccMetadataSetByGidsAndDatasetId(List<Integer> sampleIds, Integer datasetId, SetOperation operation) throws MiddlewareQueryException { Dataset dataset1 = new Dataset(); dataset1.setDatasetId(datasetId); List<AccMetadataSet> dataValues = new ArrayList<AccMetadataSet>(); try { if (sampleIds != null && !sampleIds.isEmpty()) { String queryString = SetOperation.IN.equals(operation) ? AccMetadataSetDAO.GET_ACC_METADATASETS_BY_DATASET_ID_AND_IN_GIDS : AccMetadataSetDAO.GET_ACC_METADATASETS_BY_DATASET_ID_AND_NOT_IN_GIDS; SQLQuery query = this.getSession().createSQLQuery(queryString); query.setParameterList("sampleIds", sampleIds); query.setParameter("datasetId", datasetId); List results = query.list(); for (Object o : results) { Object[] result = (Object[]) o; if (result != null) { Integer accMetadataSetId = (Integer) result[0]; Integer sampleId = (Integer) result[1]; Sample sample = new Sample(); sample.setSampleId(sampleId); AccMetadataSet dataElement = new AccMetadataSet(accMetadataSetId, dataset1, sample, null); dataValues.add(dataElement); } } } } catch (HibernateException e) { throw new MiddlewareQueryException("Error with getAccMetadataSetByGidsAndDatasetId(sampleIds=" + sampleIds + ", datasetId=" + datasetId + ") query from AccMetadataSet: " + e.getMessage(), e); } return dataValues; }
From source file:org.generationcp.middleware.dao.gdms.AccMetadataSetDAO.java
License:Open Source License
@SuppressWarnings("unchecked") //FIXME/*from w w w . j a v a 2 s .co m*/ public List<Object> getUniqueAccMetaDatsetByGids(List<Integer> gids) throws MiddlewareQueryException { try { SQLQuery query = this.getSession().createSQLQuery(AccMetadataSetDAO.GET_UNIQUE_ACC_METADATASET_BY_GIDS); query.setParameterList("gids", gids); query.addScalar("gid", Hibernate.INTEGER); query.addScalar("nid", Hibernate.INTEGER); query.addScalar("acc_sample_id", Hibernate.INTEGER); return query.list(); } catch (HibernateException e) { throw new MiddlewareQueryException("Error with getUniqueAccMetaDatasetByGids(" + gids + ") query from AccMetadataSet: " + e.getMessage(), e); } }
From source file:org.generationcp.middleware.dao.gdms.AlleleValuesDAO.java
License:Open Source License
public List<AllelicValueElement> getAlleleValuesByMarkerId(List<Integer> markerIdList) throws MiddlewareQueryException { List<AllelicValueElement> returnVal = new ArrayList<AllelicValueElement>(); if (markerIdList == null || markerIdList.isEmpty()) { return returnVal; }/*from ww w . j a v a2 s .c o m*/ try { SQLQuery query = this.getSession().createSQLQuery(AlleleValuesDAO.GET_ALLELIC_VALUES_BY_MARKER_IDS); query.setParameterList("markerIdList", markerIdList); List results = query.list(); for (Object o : results) { Object[] result = (Object[]) o; if (result != null) { Integer anId = (Integer) result[0]; Integer datasetId = (Integer) result[1]; Integer markerId = (Integer) result[2]; Integer gId = (Integer) result[3]; String alleleBinValue = (String) result[4]; Integer peakHeight = (Integer) result[5]; Integer markerSampleId = (Integer) result[6]; Integer accSampleId = (Integer) result[7]; AllelicValueElement value = new AllelicValueElement(anId, datasetId, gId, markerId, alleleBinValue, peakHeight, markerSampleId, accSampleId); returnVal.add(value); } } } catch (HibernateException e) { this.logAndThrowException( "Error with getAlleleValuesByMarkerId() query from AlleleValues: " + e.getMessage(), e); } return returnVal; }
From source file:org.generationcp.middleware.dao.gdms.AlleleValuesDAO.java
License:Open Source License
public long countAlleleValuesByGids(List<Integer> gids) throws MiddlewareQueryException { try {/* w w w .j av a 2 s .co m*/ if (gids != null && !gids.isEmpty()) { SQLQuery query = this.getSession().createSQLQuery(AlleleValuesDAO.COUNT_ALLELE_VALUES_BY_GIDS); query.setParameterList("gids", gids); BigInteger result = (BigInteger) query.uniqueResult(); if (result != null) { return result.longValue(); } } } catch (HibernateException e) { this.logAndThrowException("Error with countAlleleValuesByGids(gids=" + gids + ") query from AlleleValues: " + e.getMessage(), e); } return 0; }
From source file:org.generationcp.middleware.dao.gdms.AlleleValuesDAO.java
License:Open Source License
public List<AllelicValueElement> getIntAlleleValuesForPolymorphicMarkersRetrieval(List<Integer> gids, int start, int numOfRows) throws MiddlewareQueryException { List<AllelicValueElement> values = new ArrayList<AllelicValueElement>(); try {/*ww w . j av a2 s.c o m*/ if (gids != null && !gids.isEmpty()) { SQLQuery query = this.getSession().createSQLQuery( AlleleValuesDAO.GET_INT_ALLELE_VALUES_FOR_POLYMORPHIC_MARKERS_RETRIEVAL_BY_GIDS); query.setParameterList("gids", gids); query.setFirstResult(start); query.setMaxResults(numOfRows); List results = query.list(); for (Object o : results) { Object[] result = (Object[]) o; if (result != null) { Integer datasetId = (Integer) result[0]; Integer gid = (Integer) result[1]; Integer markerId = (Integer) result[2]; String markerName = (String) result[3]; String alleleBinValue = (String) result[4]; Integer peakHeight = (Integer) result[5]; Integer markerSampleId = (Integer) result[6]; Integer accSampleId = (Integer) result[7]; AllelicValueElement allelicValueElement = new AllelicValueElement(datasetId, gid, markerId, markerName, alleleBinValue, peakHeight, markerSampleId, accSampleId); values.add(allelicValueElement); } } } } catch (HibernateException e) { this.logAndThrowException("Error with getIntAlleleValuesForPolymorphicMarkersRetrieval(gids=" + gids + ") query from AlleleValues: " + e.getMessage(), e); } return values; }
From source file:org.generationcp.middleware.dao.gdms.AlleleValuesDAO.java
License:Open Source License
public long countIntAlleleValuesForPolymorphicMarkersRetrieval(List<Integer> gids) throws MiddlewareQueryException { try {//w ww.j a va2s .c om if (gids != null && !gids.isEmpty()) { SQLQuery query = this.getSession().createSQLQuery( AlleleValuesDAO.COUNT_INT_ALLELE_VALUES_FOR_POLYMORPHIC_MARKERS_RETRIEVAL_BY_GIDS); query.setParameterList("gids", gids); BigInteger result = (BigInteger) query.uniqueResult(); if (result != null) { return result.longValue(); } return 0; } } catch (HibernateException e) { this.logAndThrowException("Error with countCharAlleleValuesForPolymorphicMarkersRetrieval(gids=" + gids + ") query from AlleleValues: " + e.getMessage(), e); } return 0; }
From source file:org.generationcp.middleware.dao.gdms.AlleleValuesDAO.java
License:Open Source License
public List<AllelicValueElement> getCharAlleleValuesForPolymorphicMarkersRetrieval(List<Integer> gids, int start, int numOfRows) throws MiddlewareQueryException { List<AllelicValueElement> values = new ArrayList<AllelicValueElement>(); try {// w ww. j ava2s .co m if (gids != null && !gids.isEmpty()) { SQLQuery query = this.getSession().createSQLQuery( AlleleValuesDAO.GET_CHAR_ALLELE_VALUES_FOR_POLYMORPHIC_MARKERS_RETRIEVAL_BY_GIDS); query.setParameterList("gids", gids); query.setFirstResult(start); query.setMaxResults(numOfRows); List results = query.list(); for (Object o : results) { Object[] result = (Object[]) o; if (result != null) { Integer datasetId = (Integer) result[0]; Integer gid = (Integer) result[1]; Integer markerId = (Integer) result[2]; String markerName = (String) result[3]; String charValue = (String) result[4]; Integer markerSampleId = (Integer) result[5]; Integer accSampleId = (Integer) result[6]; AllelicValueElement allelicValueElement = new AllelicValueElement(datasetId, gid, markerId, markerName, charValue, markerSampleId, accSampleId); values.add(allelicValueElement); } } } } catch (HibernateException e) { this.logAndThrowException("Error with getCharAlleleValuesForPolymorphicMarkersRetrieval(gids=" + gids + ") query from AlleleValues: " + e.getMessage(), e); } return values; }
From source file:org.generationcp.middleware.dao.gdms.AlleleValuesDAO.java
License:Open Source License
public long countCharAlleleValuesForPolymorphicMarkersRetrieval(List<Integer> gids) throws MiddlewareQueryException { try {// ww w . jav a2s . c o m if (gids != null && !gids.isEmpty()) { SQLQuery query = this.getSession().createSQLQuery( AlleleValuesDAO.COUNT_CHAR_ALLELE_VALUES_FOR_POLYMORPHIC_MARKERS_RETRIEVAL_BY_GIDS); query.setParameterList("gids", gids); BigInteger result = (BigInteger) query.uniqueResult(); if (result != null) { return result.longValue(); } } } catch (HibernateException e) { this.logAndThrowException("Error with countCharAlleleValuesForPolymorphicMarkersRetrieval(gids=" + gids + ") query from AlleleValues: " + e.getMessage(), e); } return 0; }
From source file:org.generationcp.middleware.dao.gdms.AlleleValuesDAO.java
License:Open Source License
public List<AllelicValueElement> getMappingAlleleValuesForPolymorphicMarkersRetrieval(List<Integer> gids, int start, int numOfRows) throws MiddlewareQueryException { try {/*from w w w .j av a2 s. c om*/ if (gids != null && !gids.isEmpty()) { SQLQuery query = this.getSession().createSQLQuery( AlleleValuesDAO.GET_MAPPING_ALLELE_VALUES_FOR_POLYMORPHIC_MARKERS_RETRIEVAL_BY_GIDS); query.setParameterList("gids", gids); query.setFirstResult(start); query.setMaxResults(numOfRows); List results = query.list(); List<AllelicValueElement> values = new ArrayList<AllelicValueElement>(); for (Object o : results) { Object[] result = (Object[]) o; if (result != null) { Integer datasetId = (Integer) result[0]; Integer gid = (Integer) result[1]; Integer markerId = (Integer) result[2]; String markerName = (String) result[3]; String data = (String) result[4]; Integer markerSampleId = (Integer) result[5]; Integer accSampleId = (Integer) result[6]; AllelicValueElement allelicValueElement = new AllelicValueElement(datasetId, gid, markerId, markerName, data, markerSampleId, accSampleId); values.add(allelicValueElement); } } return values; } } catch (HibernateException e) { this.logAndThrowException("Error with getMappingAlleleValuesForPolymorphicMarkersRetrieval(gids=" + gids + ") query from AlleleValues: " + e.getMessage(), e); } return new ArrayList<AllelicValueElement>(); }
From source file:org.generationcp.middleware.dao.gdms.AlleleValuesDAO.java
License:Open Source License
public long countMappingAlleleValuesForPolymorphicMarkersRetrieval(List<Integer> gids) throws MiddlewareQueryException { try {/* w w w. j a v a 2s . c o m*/ if (gids != null && !gids.isEmpty()) { SQLQuery query = this.getSession().createSQLQuery( AlleleValuesDAO.COUNT_MAPPING_ALLELE_VALUES_FOR_POLYMORPHIC_MARKERS_RETRIEVAL_BY_GIDS); query.setParameterList("gids", gids); BigInteger result = (BigInteger) query.uniqueResult(); if (result != null) { return result.longValue(); } } } catch (HibernateException e) { this.logAndThrowException("Error with countMappingAlleleValuesForPolymorphicMarkersRetrieval(gids=" + gids + ") query from AlleleValues: " + e.getMessage(), e); } return 0; }