List of usage examples for org.hibernate SQLQuery uniqueResult
R uniqueResult();
From source file:org.generationcp.middleware.dao.gdms.MarkerInfoDAO.java
License:Open Source License
/** * Count the number of entries in marker info corresponding to the given db accession id. * * @param dbAccessionId the db accession id * @return the count//from w w w.j av a 2 s . c om * @throws MiddlewareQueryException */ public long countByDbAccessionId(String dbAccessionId) throws MiddlewareQueryException { if (dbAccessionId == null) { return 0; } try { SQLQuery query = this.getSession().createSQLQuery(MarkerInfoDAO.COUNT_BY_DB_ACCESSION_ID); query.setParameter("dbAccessionId", dbAccessionId); BigInteger result = (BigInteger) query.uniqueResult(); if (result != null) { return result.longValue(); } return 0; } catch (HibernateException e) { this.logAndThrowException("Error with countByDbAccessionId(" + dbAccessionId + ") query from MarkerInfo: " + e.getMessage(), e); } return 0; }
From source file:org.generationcp.middleware.dao.gdms.MarkerMetadataSetDAO.java
License:Open Source License
public long countMarkersBySampleIdAndDatasetIds(final Integer sampleId, final List<Integer> datasetIds) throws MiddlewareQueryException { long count = 0; try {/*from w w w . j a v a 2 s.co m*/ if (sampleId != null) { SQLQuery query = this.getSession() .createSQLQuery(MarkerMetadataSetDAO.COUNT_MARKERS_BY_SAMPLEID_AND_DATASETS); query.setParameterList("datasetids", datasetIds); query.setParameter("sampleId", sampleId); BigInteger result = (BigInteger) query.uniqueResult(); if (result != null) { count = result.longValue(); } } } catch (HibernateException e) { this.logAndThrowException("Error with countMarkersBySampleIdAndDatasetIds(sampleId=" + sampleId + ", datasetIds=" + datasetIds + ") query from MarkerMetadataSet: " + e.getMessage(), e); } return count; }
From source file:org.generationcp.middleware.dao.gdms.MarkerMetadataSetDAO.java
License:Open Source License
public long countByDatasetIds(final List<Integer> datasetIds) throws MiddlewareQueryException { long count = 0; try {//from w w w . j av a 2 s .co m if (datasetIds != null && !datasetIds.isEmpty()) { SQLQuery query = this.getSession().createSQLQuery(MarkerMetadataSetDAO.COUNT_MARKER_BY_DATASET_IDS); query.setParameterList("datasetIds", datasetIds); BigInteger result = (BigInteger) query.uniqueResult(); if (result != null) { count = result.longValue(); } } } catch (HibernateException e) { this.logAndThrowException("Error with countByDatasetIds=" + datasetIds + ") query from MarkerMetadataSet: " + e.getMessage(), e); } return count; }
From source file:org.generationcp.middleware.dao.gdms.QtlDAO.java
License:Open Source License
public long countMapIDsByQTLName(String qtlName) throws MiddlewareQueryException { try {//from ww w .j a v a2s .c o m SQLQuery query; query = this.getSession().createSQLQuery(QtlDAO.COUNT_MAP_IDS_BY_QTL_NAME); query.setParameter("qtl_name", qtlName); BigInteger result = (BigInteger) query.uniqueResult(); if (result != null) { return result.longValue(); } else { return 0; } } catch (HibernateException e) { this.logAndThrowException( "Error with countMapIDsByQTLName(qtlName=" + qtlName + ") query from QTL: " + e.getMessage(), e); } return 0L; }
From source file:org.generationcp.middleware.dao.gdms.QtlDetailsDAO.java
License:Open Source License
public long countMarkerIdsByQtl(String qtlName, String chromosome, float min, float max) throws MiddlewareQueryException { try {//from w w w. j av a2 s. c o m SQLQuery query = this.getSession().createSQLQuery(QtlDetailsDAO.COUNT_MARKER_IDS_BY_QTL); query.setParameter("qtlName", qtlName); query.setParameter("chromosome", chromosome); query.setParameter("min", min); query.setParameter("max", max); BigInteger result = (BigInteger) query.uniqueResult(); if (result != null) { return result.longValue(); } } catch (HibernateException e) { this.logAndThrowException("Error with countMarkerIdsByQtl() query from QtlDetails: " + e.getMessage(), e); } return 0; }
From source file:org.generationcp.middleware.dao.gdms.QtlDetailsDAO.java
License:Open Source License
public Integer getMapIdByQtlName(String qtlName) throws MiddlewareQueryException { try {/*ww w. jav a 2 s . co m*/ SQLQuery query = this.getSession().createSQLQuery(QtlDetailsDAO.GET_MAP_ID_BY_QTL); query.setParameter("qtlName", qtlName); return (Integer) query.uniqueResult(); } catch (HibernateException e) { this.logAndThrowException("Error with getMapIdByQtlName() query from QtlDetails: " + e.getMessage(), e); } return 0; }
From source file:org.generationcp.middleware.dao.gdms.QtlDetailsDAO.java
License:Open Source License
public long countMapIdsByQtlName(String qtlName) throws MiddlewareQueryException { try {//w ww. ja v a 2 s .c o m SQLQuery query = this.getSession().createSQLQuery(QtlDetailsDAO.COUNT_MAP_IDS_BY_QTL); query.setParameter("qtlName", qtlName); BigInteger result = (BigInteger) query.uniqueResult(); if (result != null) { return result.longValue(); } } catch (HibernateException e) { this.logAndThrowException("Error with countMapIdsByQtlName() query from QtlDetails: " + e.getMessage(), e); } return 0; }
From source file:org.generationcp.middleware.dao.gdms.QtlDetailsDAO.java
License:Open Source License
public long countMarkerIdsByQtl(Integer mapId, String qtlName, String chromosome, int min, int max) throws MiddlewareQueryException { try {/*from w w w . j a v a 2 s . c om*/ SQLQuery query = this.getSession().createSQLQuery(QtlDetailsDAO.COUNT_MARKER_IDS_BY_QTL_AND_MAP_ID); query.setParameter("qtlName", qtlName); query.setParameter("chromosome", chromosome); query.setParameter("min", min); query.setParameter("max", max); query.setParameter("mapId", mapId); BigInteger result = (BigInteger) query.uniqueResult(); if (result != null) { return result.longValue(); } } catch (HibernateException e) { this.logAndThrowException("Error with countMarkerIdsByQtl() query from QtlDetails: " + e.getMessage(), e); } return 0; }
From source file:org.generationcp.middleware.dao.gdms.QtlDetailsDAO.java
License:Open Source License
public long countQtlTraitsByDatasetId(Integer datasetId) throws MiddlewareQueryException { try {//from w ww. j ava 2 s .c o m if (datasetId != null) { SQLQuery query = this.getSession().createSQLQuery(QtlDetailsDAO.COUNT_QTL_TRAITS_BY_DATASET_ID); query.setParameter("datasetId", datasetId); BigInteger result = (BigInteger) query.uniqueResult(); if (result != null) { return result.longValue(); } } } catch (HibernateException e) { this.logAndThrowException( "Error with countQtlTraitsByDatasetId() query from QtlDetails: " + e.getMessage(), e); } return 0; }
From source file:org.generationcp.middleware.dao.gdms.QtlDetailsDAO.java
License:Open Source License
public long countQtlDataByQtlTraits(List<Integer> qtlTraits) throws MiddlewareQueryException { try {// w ww. j a v a 2 s .c om if (qtlTraits != null && !qtlTraits.isEmpty()) { SQLQuery query = this.getSession().createSQLQuery(QtlDetailsDAO.COUNT_QTL_DATA_BY_QTL_TRAITS); query.setParameterList("qtlTraits", qtlTraits); BigInteger result = (BigInteger) query.uniqueResult(); if (result != null) { return result.longValue(); } } } catch (HibernateException e) { this.logAndThrowException( "Error with countQtlDataByQtlTraits() query from QtlDetails: " + e.getMessage(), e); } return 0; }