List of usage examples for org.hibernate SQLQuery setFirstResult
@Override
Query<R> setFirstResult(int startPosition);
From source file:org.generationcp.middleware.dao.gdms.MarkerDAO.java
License:Open Source License
/** * Gets the all db accession ids./*from w w w . j a v a 2 s. c o m*/ * * @param start the start * @param numOfRows the num of rows * @return all non-empty db accession ids * @ */ public List<String> getAllDbAccessionIds(final int start, final int numOfRows) { try { final SQLQuery query = this.getSession().createSQLQuery(MarkerDAO.GET_ALL_DB_ACCESSION_IDS); query.setFirstResult(start); query.setMaxResults(numOfRows); return query.list(); } catch (final HibernateException e) { LOG.error(e.getMessage(), e); throw new MiddlewareQueryException( "Error with getAllDbAccessionIds() query from Marker: " + e.getMessage(), e); } }
From source file:org.generationcp.middleware.dao.gdms.MarkerDAO.java
License:Open Source License
public List<Marker> getMarkersByIds(final List<Integer> markerIds, final int start, final int numOfRows) { if (markerIds == null || markerIds.isEmpty()) { return new ArrayList<>(); }/*from w ww . j a v a 2 s.co m*/ try { final SQLQuery query = this.getSession().createSQLQuery(MarkerDAO.GET_MARKERS_BY_IDS); query.setParameterList("markerIdList", markerIds); query.setFirstResult(start); query.setMaxResults(numOfRows); final List results = query.list(); final List<Marker> dataValues = new ArrayList<>(); for (final Object o : results) { final Object[] result = (Object[]) o; if (result != null) { dataValues.add(this.convertToMarker(result)); } } return dataValues; } catch (final HibernateException e) { LOG.error(e.getMessage(), e); throw new MiddlewareQueryException("Error with getMarkersByIds() query from Marker: " + e.getMessage(), e); } }
From source file:org.generationcp.middleware.dao.gdms.MarkerDAO.java
License:Open Source License
public Set<Integer> getMarkerIDsByMapIDAndLinkageBetweenStartPosition(final int mapID, final String linkageGroup, final double startPos, final double endPos, final int start, final int numOfRows) { try {//w ww .jav a 2s .c o m final SQLQuery query; query = this.getSession() .createSQLQuery(MarkerDAO.GET_MARKER_IDS_BY_MAP_ID_AND_LINKAGE_BETWEEN_START_POSITION); query.setParameter("mapId", mapID); query.setParameter("linkageGroup", linkageGroup); query.setParameter("startPosition", startPos); query.setParameter("endPosition", endPos); query.setFirstResult(start); query.setMaxResults(numOfRows); final Set<Integer> markerIDSet = new TreeSet<>(query.list()); return markerIDSet; } catch (final HibernateException e) { LOG.error(e.getMessage(), e); throw new MiddlewareQueryException("Error with getMarkerIdsByMapIDAndLinkageBetweenStartPosition(mapID=" + mapID + ", linkageGroup=" + linkageGroup + ", start=" + start + ", numOfRows=" + numOfRows + ") query from MarkerOnMap: " + e.getMessage(), e); } }
From source file:org.generationcp.middleware.dao.gdms.MarkerInfoDAO.java
License:Open Source License
/** * Gets the list of marker info objects corresponding to the given marker name. * * @param markerName the marker name//w w w .ja va2s .c o m * @param start the start row * @param numOfRows the number of rows to retrieve * @return the list of MarkerInfo objects by marker name * @throws MiddlewareQueryException */ @SuppressWarnings("rawtypes") public List<MarkerInfo> getByMarkerName(String markerName, int start, int numOfRows) throws MiddlewareQueryException { if (markerName == null) { return new ArrayList<MarkerInfo>(); } try { SQLQuery query = this.getSession().createSQLQuery(MarkerInfoDAO.GET_BY_MARKER_NAME); query.setParameter("markerName", markerName); query.setFirstResult(start); query.setMaxResults(numOfRows); List results = query.list(); ArrayList<MarkerInfo> toReturn = new ArrayList<MarkerInfo>(); for (Object o : results) { Object[] result = (Object[]) o; if (result != null) { toReturn.add(this.convertFromObject(result)); } } return toReturn; } catch (HibernateException e) { this.logAndThrowException("Error with getByMarkerName(markerName=" + markerName + ") query from MarkerInfo: " + e.getMessage(), e); } return new ArrayList<MarkerInfo>(); }
From source file:org.generationcp.middleware.dao.gdms.MarkerInfoDAO.java
License:Open Source License
/** * Gets the list of marker info objects corresponding to the given genotype. * * @param genotype the genotype//from w w w .j ava 2s .c o m * @param start the start row * @param numOfRows the number of rows to retrieve * @return the list of MarkerInfo objects by genotype * @throws MiddlewareQueryException */ @SuppressWarnings("rawtypes") public List<MarkerInfo> getByGenotype(String genotype, int start, int numOfRows) throws MiddlewareQueryException { if (genotype == null) { return new ArrayList<MarkerInfo>(); } try { SQLQuery query = this.getSession().createSQLQuery(MarkerInfoDAO.GET_BY_GENOTYPE); query.setParameter("genotype", genotype); query.setFirstResult(start); query.setMaxResults(numOfRows); List results = query.list(); ArrayList<MarkerInfo> toReturn = new ArrayList<MarkerInfo>(); for (Object o : results) { Object[] result = (Object[]) o; if (result != null) { Integer markerId = (Integer) result[0]; String markerType = (String) result[1]; String markerName = (String) result[2]; String species = (String) result[3]; String accessionId = (String) result[4]; String reference = (String) result[5]; String genotype2 = (String) result[6]; String ploidy = (String) result[7]; String motif = (String) result[8]; String forwardPrimer = (String) result[9]; String reversePrimer = (String) result[10]; String productSize = (String) result[11]; Float annealingTemp = (Float) result[12]; String amplification = (String) result[13]; String principalInvestigator = (String) result[14]; String contact = (String) result[15]; String institute = (String) result[16]; BigInteger genotypesCount = (BigInteger) result[17]; MarkerInfo markerInfo = new MarkerInfo(markerId, markerType, markerName, species, accessionId, reference, genotype2, ploidy, motif, forwardPrimer, reversePrimer, productSize, annealingTemp, amplification, principalInvestigator, contact, institute, genotypesCount); toReturn.add(markerInfo); } } return toReturn; } catch (HibernateException e) { this.logAndThrowException( "Error with getByGenotype(genotype=" + genotype + ") query from MarkerInfo: " + e.getMessage(), e); } return new ArrayList<MarkerInfo>(); }
From source file:org.generationcp.middleware.dao.gdms.MarkerInfoDAO.java
License:Open Source License
/** * Gets the list of marker info objects corresponding to the given db accession id. * * @param dbAccessionId the db accession id * @param start the start row/* www. j av a2 s . c o m*/ * @param numOfRows the number of rows to retrieve * @return the list of MarkerInfo objects by db accession id * @throws MiddlewareQueryException */ @SuppressWarnings("rawtypes") public List<MarkerInfo> getByDbAccessionId(String dbAccessionId, int start, int numOfRows) throws MiddlewareQueryException { if (dbAccessionId == null) { return new ArrayList<MarkerInfo>(); } try { SQLQuery query = this.getSession().createSQLQuery(MarkerInfoDAO.GET_BY_DB_ACCESSION_ID); query.setParameter("dbAccessionId", dbAccessionId); query.setFirstResult(start); query.setMaxResults(numOfRows); List results = query.list(); ArrayList<MarkerInfo> toReturn = new ArrayList<MarkerInfo>(); for (Object o : results) { Object[] result = (Object[]) o; if (result != null) { Integer markerId = (Integer) result[0]; String markerType = (String) result[1]; String markerName = (String) result[2]; String species = (String) result[3]; String accessionId = (String) result[4]; String reference = (String) result[5]; String genotype = (String) result[6]; String ploidy = (String) result[7]; String motif = (String) result[8]; String forwardPrimer = (String) result[9]; String reversePrimer = (String) result[10]; String productSize = (String) result[11]; Float annealingTemp = (Float) result[12]; String amplification = (String) result[13]; String principalInvestigator = (String) result[14]; String contact = (String) result[15]; String institute = (String) result[16]; BigInteger genotypesCount = (BigInteger) result[17]; MarkerInfo markerInfo = new MarkerInfo(markerId, markerType, markerName, species, accessionId, reference, genotype, ploidy, motif, forwardPrimer, reversePrimer, productSize, annealingTemp, amplification, principalInvestigator, contact, institute, genotypesCount); toReturn.add(markerInfo); } } return toReturn; } catch (HibernateException e) { this.logAndThrowException("Error with getByDbAccessionId(dbAccessionId=" + dbAccessionId + ") query from MarkerInfo: " + e.getMessage(), e); } return new ArrayList<MarkerInfo>(); }
From source file:org.generationcp.middleware.dao.gdms.MarkerMetadataSetDAO.java
License:Open Source License
@SuppressWarnings("unchecked") public List<Integer> getMarkersBySampleIdAndDatasetIds(final Integer sampleId, final List<Integer> datasetIds, final int start, final int numOfRows) throws MiddlewareQueryException { List<Integer> markerIds = new ArrayList<Integer>(); try {//from w w w.j a v a2s. c o m if (sampleId != null && datasetIds != null) { SQLQuery query = this.getSession() .createSQLQuery(MarkerMetadataSetDAO.GET_MARKERS_BY_SAMPLEID_AND_DATASETS); query.setParameterList("datasetids", datasetIds); query.setParameter("sampleId", sampleId); query.setFirstResult(start); query.setMaxResults(numOfRows); markerIds = query.list(); } else { return new ArrayList<Integer>(); } } catch (HibernateException e) { this.logAndThrowException("Error with getMarkersBySampleIdAndDatasetIds(sampleID=" + sampleId + ", datasetIds=" + datasetIds + ") query from MarkerMetadataSet: " + e.getMessage(), e); } return markerIds; }
From source file:org.generationcp.middleware.dao.gdms.QtlDAO.java
License:Open Source License
@SuppressWarnings("unchecked") public List<Integer> getQtlIdByName(String name, int start, int numOfRows) throws MiddlewareQueryException { try {// ww w . j a v a2s. co m SQLQuery query = this.getSession().createSQLQuery(QtlDAO.GET_QTL_ID_BY_NAME); query.setParameter("qtlName", name); query.setFirstResult(start); query.setMaxResults(numOfRows); return query.list(); } catch (HibernateException e) { this.logAndThrowException( "Error with getQtlIdByName(name=" + name + ") query from gdms_qtl: " + e.getMessage(), e); } return new ArrayList<Integer>(); }
From source file:org.generationcp.middleware.dao.gdms.QtlDAO.java
License:Open Source License
public List<QtlDetailElement> getQtlAndQtlDetailsByQtlIds(List<Integer> qtlIDs, int start, int numOfRows) throws MiddlewareQueryException { List<QtlDetailElement> toReturn = new ArrayList<QtlDetailElement>(); try {// w w w. j av a2 s . c om if (qtlIDs != null && !qtlIDs.isEmpty()) { SQLQuery query = this.getSession().createSQLQuery(QtlDAO.GET_QTL_AND_QTL_DETAILS_BY_QTL_IDS); query.setParameterList("qtl_id_list", qtlIDs); query.setFirstResult(start); query.setMaxResults(numOfRows); toReturn = this.getQtlAndQtlDetails(query); } } catch (HibernateException e) { this.logAndThrowException("Error with getQtlAndQtlDetailsByQtlIds(qtl ids=" + qtlIDs + ") query from gdms_qtl_details: " + e.getMessage(), e); } return toReturn; }
From source file:org.generationcp.middleware.dao.gdms.QtlDAO.java
License:Open Source License
public List<QtlDetailElement> getQtlAndQtlDetailsByName(String name, int start, int numOfRows) throws MiddlewareQueryException { List<QtlDetailElement> toReturn = new ArrayList<QtlDetailElement>(); try {/* ww w. ja v a2s.c om*/ SQLQuery query = this.getSession().createSQLQuery(QtlDAO.GET_QTL_AND_QTL_DETAILS_BY_NAME); query.setParameter("qtlName", name); query.setFirstResult(start); query.setMaxResults(numOfRows); toReturn = this.getQtlAndQtlDetails(query); } catch (HibernateException e) { this.logAndThrowException("Error with getQtlDetailsByName(name=" + name + ") query from gdms_qtl_details: " + e.getMessage(), e); } return toReturn; }