List of usage examples for org.hibernate SQLQuery setMaxResults
@Override
Query<R> setMaxResults(int maxResult);
From source file:org.generationcp.middleware.dao.FactorDAO.java
License:Open Source License
@SuppressWarnings("unchecked") public Set<Integer> getGIDSByObservationUnitIds(Set<Integer> ounitIds, int start, int numOfRows) throws MiddlewareQueryException { Set<Integer> results = new HashSet<Integer>(); try {/* w w w .j a v a2s. c o m*/ SQLQuery levelNQuery = getSession() .createSQLQuery(Factor.GET_GID_FROM_NUMERIC_LEVELS_GIVEN_OBSERVATION_UNIT_IDS); levelNQuery.setParameterList("ounitids", ounitIds); levelNQuery.setFirstResult(start); levelNQuery.setMaxResults(numOfRows); List<Double> gids1 = levelNQuery.list(); for (Double gid : gids1) { results.add(gid.intValue()); } SQLQuery levelCQuery = getSession() .createSQLQuery(Factor.GET_GID_FROM_CHARACTER_LEVELS_GIVEN_OBSERVATION_UNIT_IDS); levelCQuery.setParameterList("ounitids", ounitIds); levelCQuery.setFirstResult(start); levelCQuery.setMaxResults(numOfRows); List<String> gids2 = levelCQuery.list(); for (String gid : gids2) { results.add(Integer.parseInt(gid)); } return results; } catch (HibernateException e) { throw new MiddlewareQueryException("Error with getGIDSByObservationUnitIds(ounitIds=" + ounitIds + ") query from Factor: " + e.getMessage(), e); } }
From source file:org.generationcp.middleware.dao.gdms.AccMetadataSetDAO.java
License:Open Source License
@SuppressWarnings("unchecked") //FIXME//from w w w. j a va 2 s . c o m public Set<Integer> getNIdsByMarkerIdsAndDatasetIdsAndNotGIds(List<Integer> datasetIds, List<Integer> markerIds, List<Integer> gIds, int start, int numOfRows) throws MiddlewareQueryException { try { if (datasetIds != null && !datasetIds.isEmpty()) { StringBuilder queryString = new StringBuilder( AccMetadataSetDAO.GET_NIDS_BY_DATASET_IDS_AND_MARKER_IDS_AND_NOT_GIDS_SELECT); queryString.append(AccMetadataSetDAO.GET_NIDS_BY_DATASET_IDS_AND_MARKER_IDS_AND_NOT_GIDS_FROM); if (markerIds != null && !markerIds.isEmpty()) { queryString.append(AccMetadataSetDAO.GET_NIDS_BY_DATASET_IDS_FILTER_BY_MARKER_IDS); } if (gIds != null && !gIds.isEmpty()) { queryString.append(AccMetadataSetDAO.GET_NIDS_BY_DATASET_IDS_FILTER_NOT_BY_GIDS); } queryString.append(AccMetadataSetDAO.GET_NIDS_BY_DATASET_IDS_ORDER); SQLQuery query; query = this.getSession().createSQLQuery(queryString.toString()); query.setParameterList("represnos", datasetIds); if (markerIds != null && !markerIds.isEmpty()) { query.setParameterList("markerids", markerIds); } if (gIds != null && !gIds.isEmpty()) { query.setParameterList("gids", gIds); } query.setFirstResult(start); query.setMaxResults(numOfRows); return new TreeSet<Integer>(query.list()); } } catch (HibernateException e) { throw new MiddlewareQueryException( "Error with getNIDsByDatasetIdsAndMarkerIdsAndNotGIDs(datasetIds=" + datasetIds + ", markerIds=" + markerIds + ", gIds=" + gIds + ") query from AccMetadataSet: " + e.getMessage(), e); } return new TreeSet<Integer>(); }
From source file:org.generationcp.middleware.dao.gdms.AlleleValuesDAO.java
License:Open Source License
/** * Gets the allelic values based on the given dataset id. The result is limited by the start and numOfRows parameters. * * @param datasetId the dataset id/* w w w. j a va2s . c o m*/ * @param start the start of the rows to retrieve * @param numOfRows the number of rows to retrieve * @return the Allelic Values (germplasm id, data value, and marker id) for the given dataset id * @throws MiddlewareQueryException the MiddlewareQueryException */ public List<AllelicValueWithMarkerIdElement> getAllelicValuesByDatasetId(Integer datasetId, int start, int numOfRows) throws MiddlewareQueryException { List<AllelicValueWithMarkerIdElement> toReturn = new ArrayList<AllelicValueWithMarkerIdElement>(); try { if (datasetId != null) { SQLQuery query = this.getSession().createSQLQuery(AlleleValuesDAO.GET_ALLELIC_VALUES_BY_DATASET_ID); query.setParameter("datasetId", datasetId); query.setFirstResult(start); query.setMaxResults(numOfRows); List results = query.list(); for (Object o : results) { Object[] result = (Object[]) o; if (result != null) { Integer gid = (Integer) result[0]; Integer markerId = (Integer) result[1]; String data = (String) result[2]; Integer peakHeight = (Integer) result[3]; Integer markerSampleId = (Integer) result[4]; Integer accSampleId = (Integer) result[5]; AllelicValueWithMarkerIdElement allelicValueElement = new AllelicValueWithMarkerIdElement( gid, data, markerId, peakHeight, markerSampleId, accSampleId); toReturn.add(allelicValueElement); } } } } catch (HibernateException e) { this.logAndThrowException("Error with getAllelicValuesByDatasetId(datasetId=" + datasetId + ") query from AlleleValues: " + e.getMessage(), e); } return toReturn; }
From source file:org.generationcp.middleware.dao.gdms.AlleleValuesDAO.java
License:Open Source License
/** * Gets the gids by marker id.//from w ww .j a va 2s .c o m * * @param markerId the marker id * @param start the start * @param numOfRows the num of rows * @return the gI ds by marker id * @throws MiddlewareQueryException the MiddlewareQueryException */ @SuppressWarnings("unchecked") public List<Integer> getGIDsByMarkerId(Integer markerId, int start, int numOfRows) throws MiddlewareQueryException { try { if (markerId != null) { SQLQuery query = this.getSession().createSQLQuery(AlleleValuesDAO.GET_GIDS_BY_MARKER_ID); query.setParameter("markerId", markerId); query.setFirstResult(start); query.setMaxResults(numOfRows); return query.list(); } } catch (HibernateException e) { this.logAndThrowException("Error with getGIDsByMarkerId(markerId=" + markerId + ") query from AlleleValues: " + e.getMessage(), e); } return new ArrayList<Integer>(); }
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 a 2 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 List<AllelicValueElement> getCharAlleleValuesForPolymorphicMarkersRetrieval(List<Integer> gids, int start, int numOfRows) throws MiddlewareQueryException { List<AllelicValueElement> values = new ArrayList<AllelicValueElement>(); try {/*from ww w .ja v a 2s. 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 List<AllelicValueElement> getMappingAlleleValuesForPolymorphicMarkersRetrieval(List<Integer> gids, int start, int numOfRows) throws MiddlewareQueryException { try {/*w ww . j a v a 2 s.c o m*/ 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.CharValuesDAO.java
License:Open Source License
@SuppressWarnings("unchecked") public List<Integer> getGIDsByMarkerId(final Integer markerId, final int start, final int numOfRows) { try {/*from w w w. ja v a 2s . c om*/ if (markerId != null) { SQLQuery query = this.getSession().createSQLQuery(CharValuesDAO.GET_GIDS_BY_MARKER_ID); query.setParameter("markerId", markerId); query.setFirstResult(start); query.setMaxResults(numOfRows); return query.list(); } } catch (HibernateException e) { throw new MiddlewareQueryException("Error with getGIDsByMarkerId(markerId=" + markerId + ") query from CharValues: " + e.getMessage(), e); } return new ArrayList<>(); }
From source file:org.generationcp.middleware.dao.gdms.DatasetDAO.java
License:Open Source License
public List<String> getDatasetNames(final int start, final int numOfRows) { try {//from w w w . j a va2 s .c o m SQLQuery query = this.getSession().createSQLQuery(DatasetDAO.GET_DATASET_NAMES_NOT_QTL_AND_MTA); query.setFirstResult(start); query.setMaxResults(numOfRows); return query.list(); } catch (HibernateException e) { final String errorMessage = "Error with getDatasetNames() query from Dataset: " + e.getMessage(); DatasetDAO.LOG.error(errorMessage, e); throw new MiddlewareQueryException(errorMessage, e); } }
From source file:org.generationcp.middleware.dao.gdms.DatasetDAO.java
License:Open Source License
public List<Integer> getDatasetIdsForFingerPrinting(final int start, final int numOfRows) { try {//w ww . j a v a 2s . com SQLQuery query = this.getSession().createSQLQuery(DatasetDAO.GET_DATASET_ID_NOT_MAPPING_AND_NOT_QTL); query.setFirstResult(start); query.setMaxResults(numOfRows); return query.list(); } catch (HibernateException e) { final String errorMessage = "Error with getDatasetIdsForFingerPrinting() query from Dataset: " + e.getMessage(); DatasetDAO.LOG.error(errorMessage, e); throw new MiddlewareQueryException(errorMessage, e); } }