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.AlleleValuesDAO.java
License:Open Source License
public List<MarkerSampleId> getMarkerSampleIdsByGids(List<Integer> gIds) throws MiddlewareQueryException { List<MarkerSampleId> toReturn = new ArrayList<MarkerSampleId>(); try {/*from www . j a va2 s . co m*/ if (gIds != null && !gIds.isEmpty()) { SQLQuery query = this.getSession().createSQLQuery(AlleleValuesDAO.GET_MARKER_SAMPLE_IDS_BY_GIDS); query.setParameterList("gids", gIds); List results = query.list(); for (Object o : results) { Object[] result = (Object[]) o; if (result != null) { Integer markerId = (Integer) result[0]; Integer markerSampleId = (Integer) result[1]; MarkerSampleId dataElement = new MarkerSampleId(markerId, markerSampleId); toReturn.add(dataElement); } } } } catch (HibernateException e) { this.logAndThrowException("Error with getMarkerSampleIdsByGids(gIds=" + gIds + ") query from AlleleValuesDAO: " + e.getMessage(), e); } return toReturn; }
From source file:org.generationcp.middleware.dao.gdms.AlleleValuesDAO.java
License:Open Source License
public long countByGids(List<Integer> gIds) throws MiddlewareQueryException { try {/* w w w. java 2 s .c om*/ if (gIds != null && gIds.get(0) != null) { SQLQuery query = this.getSession().createSQLQuery(AlleleValuesDAO.COUNT_BY_GIDS); query.setParameterList("gIdList", gIds); BigInteger result = (BigInteger) query.uniqueResult(); if (result != null) { return result.longValue(); } } } catch (HibernateException e) { this.logAndThrowException( "Error with countByGids(gIds=" + gIds + ") query from AlleleValuesDAO: " + e.getMessage(), e); } return 0; }
From source file:org.generationcp.middleware.dao.gdms.AlleleValuesDAO.java
License:Open Source License
@SuppressWarnings({ "deprecation", "unchecked" }) public List<Object> getUniqueAllelesByGidsAndMids(List<Integer> gids, List<Integer> mids) { List<Object> results = new ArrayList<>(); try {/*from w ww.ja v a 2s . c om*/ if (gids != null) { SQLQuery query = this.getSession() .createSQLQuery(AlleleValuesDAO.GET_UNIQUE_ALLELIC_VALUES_BY_GIDS_AND_MIDS); query.setParameterList("gids", gids); query.setParameterList("mids", mids); query.addScalar("gid", Hibernate.INTEGER); query.addScalar("marker_id", Hibernate.INTEGER); query.addScalar("allele_bin_value", Hibernate.STRING); query.addScalar("acc_sample_id", Hibernate.INTEGER); query.addScalar("marker_sample_id", Hibernate.INTEGER); results = query.list(); } } catch (HibernateException e) { this.logAndThrowException("Error with getUniqueAllelesByGidsAndMids(gids=" + gids + ") query from AlleleValuesDAO " + e.getMessage(), e); } return results; }
From source file:org.generationcp.middleware.dao.gdms.CharValuesDAO.java
License:Open Source License
@SuppressWarnings("rawtypes") public List<MarkerSampleId> getMarkerSampleIdsByGids(final List<Integer> gIds) { List<MarkerSampleId> toReturn = new ArrayList<>(); try {/*from w w w . j av a 2s . c om*/ if (gIds != null && !gIds.isEmpty()) { SQLQuery query = this.getSession().createSQLQuery(CharValuesDAO.GET_MARKER_SAMPLE_IDS_BY_GIDS); query.setParameterList("gids", gIds); List results = query.list(); for (final Object o : results) { Object[] result = (Object[]) o; if (result != null) { Integer markerId = (Integer) result[0]; Integer markerSampleId = (Integer) result[1]; MarkerSampleId dataElement = new MarkerSampleId(markerId, markerSampleId); toReturn.add(dataElement); } } } } catch (HibernateException e) { throw new MiddlewareQueryException( "Error with getMarkerIdsByGids(gIds=" + gIds + ") query from CharValues: " + e.getMessage(), e); } return toReturn; }
From source file:org.generationcp.middleware.dao.gdms.CharValuesDAO.java
License:Open Source License
@SuppressWarnings({ "deprecation", "unchecked" }) public List<Object> getUniqueCharAllelesByGidsAndMids(final List<Integer> gids, final List<Integer> mids) { List<Object> results = new ArrayList<>(); try {// w w w . j ava2 s .c om if (gids != null) { SQLQuery query = this.getSession() .createSQLQuery(CharValuesDAO.GET_UNIQUE_ALLELIC_VALUES_BY_GIDS_AND_MIDS); query.setParameterList("gids", gids); query.setParameterList("mids", mids); query.addScalar("gid", Hibernate.INTEGER); query.addScalar("marker_id", Hibernate.INTEGER); query.addScalar("char_value", Hibernate.STRING); query.addScalar("acc_sample_id", Hibernate.INTEGER); query.addScalar("marker_sample_id", Hibernate.INTEGER); results = query.list(); } } catch (HibernateException e) { throw new MiddlewareQueryException("Error with getUniqueAllelesByGidsAndMids(gids=" + gids + ") query from CharValuesDAO " + e.getMessage(), e); } return results; }
From source file:org.generationcp.middleware.dao.gdms.CharValuesDAO.java
License:Open Source License
@SuppressWarnings("rawtypes") public List<AllelicValueElement> getAlleleValuesByMarkerId(final List<Integer> markerIdList) { List<AllelicValueElement> returnVal = new ArrayList<>(); if (markerIdList == null || markerIdList.isEmpty()) { return returnVal; }/*from ww w . j a va2s . com*/ try { SQLQuery query = this.getSession().createSQLQuery(CharValuesDAO.GET_ALLELIC_VALUES_BY_MARKER_IDS); query.setParameterList("markerIdList", markerIdList); List results = query.list(); for (final Object o : results) { Object[] result = (Object[]) o; if (result != null) { Integer acId = (Integer) result[0]; Integer datasetId = (Integer) result[1]; Integer markerId = (Integer) result[2]; Integer gId = (Integer) result[3]; String data = (String) result[4]; Integer markerSampleId = (Integer) result[5]; Integer accSampleId = (Integer) result[6]; AllelicValueElement value = new AllelicValueElement(acId, datasetId, gId, markerId, data, markerSampleId, accSampleId); returnVal.add(value); } } } catch (HibernateException e) { throw new MiddlewareQueryException( "Error with getAlleleValuesByMarkerId() query from AlleleValues: " + e.getMessage(), e); } return returnVal; }
From source file:org.generationcp.middleware.dao.gdms.DartValuesDAO.java
License:Open Source License
@SuppressWarnings("rawtypes") public List<DartValues> getDartValuesByMarkerIds(List<Integer> markerIds) throws MiddlewareQueryException { List<DartValues> toReturn = new ArrayList<DartValues>(); try {// w w w. j a v a 2 s . c o m if (markerIds != null && !markerIds.isEmpty()) { SQLQuery query = this.getSession() .createSQLQuery("SELECT * " + " FROM gdms_dart_values where marker_id IN (:markerIds) "); query.setParameterList("markerIds", markerIds); List results = query.list(); for (Object o : results) { Object[] result = (Object[]) o; if (result != null) { Integer adId = (Integer) result[0]; Integer datasetId2 = (Integer) result[1]; Integer markerId = (Integer) result[2]; Integer cloneId = (Integer) result[3]; Float qValue = (Float) result[4]; Float reproducibility = (Float) result[5]; Float callRate = (Float) result[6]; Float picValue = (Float) result[7]; Float discordance = (Float) result[8]; DartValues dataElement = new DartValues(adId, datasetId2, markerId, cloneId, qValue, reproducibility, callRate, picValue, discordance); toReturn.add(dataElement); } } } } catch (HibernateException e) { this.logAndThrowException("Error with getDartValuesByMarkerIds(markerIds=" + markerIds + ") query from DartValues " + e.getMessage(), e); } return toReturn; }
From source file:org.generationcp.middleware.dao.gdms.MapDAO.java
License:Open Source License
public List<MapInfo> getMapInfoByMarkersAndMap(final List<Integer> markers, final Integer mapId) { final SQLQuery query = this.getSession().createSQLQuery(MapDAO.GET_MAP_INFO_BY_MARKERS_AND_MAP); query.setParameterList("markerIdList", markers); query.setInteger("mapId", mapId); query.addScalar("marker_id", new IntegerType()); query.addScalar("marker_name", new StringType()); query.addScalar("map_name", new StringType()); query.addScalar("map_type", new StringType()); query.addScalar("start_position", new FloatType()); query.addScalar("linkage_group", new StringType()); query.addScalar("map_unit", new StringType()); final List<MapInfo> mapInfoList = new ArrayList<MapInfo>(); try {//from w ww . j a v a 2s .c o m @SuppressWarnings("rawtypes") final List results = query.list(); for (final Object o : results) { final Object[] result = (Object[]) o; if (result != null) { final Integer markerId = (Integer) result[0]; final String markerName = (String) result[1]; final String mapName = (String) result[2]; final String mapType = (String) result[3]; final Float startPosition = (Float) result[4]; final String linkageGroup = (String) result[5]; final String mapUnit = (String) result[6]; final MapInfo mapInfo = new MapInfo(markerId, markerName, mapId, mapName, linkageGroup, startPosition, mapType, mapUnit); mapInfoList.add(mapInfo); } } } catch (final HibernateException e) { MapDAO.LOG.error(e.getMessage(), e); throw new MiddlewareQueryException("Error with getMapInfoByMarkersAndMap() query: " + e.getMessage(), e); } return mapInfoList; }
From source file:org.generationcp.middleware.dao.gdms.MapDAO.java
License:Open Source License
@SuppressWarnings("rawtypes") public List<MapDetailElement> getMapAndMarkerCountByMarkers(final List<Integer> markerIds) { final List<MapDetailElement> details = new ArrayList<MapDetailElement>(); try {/*from ww w. ja v a2 s .c om*/ final SQLQuery query = this.getSession().createSQLQuery(MapDAO.GET_MAP_AND_MARKER_COUNT_BY_MARKERS); query.setParameterList("markerIds", markerIds); final List results = query.list(); for (final Object o : results) { final Object[] result = (Object[]) o; details.add(new MapDetailElement(((BigInteger) result[1]).intValue(), null, null, result[0].toString(), null, null, null)); } } catch (final HibernateException e) { MapDAO.LOG.error(e.getMessage(), e); throw new MiddlewareQueryException( "Error with getMapAndMarkerCountByMarkers(" + markerIds + ") in MapDAO: " + e.getMessage(), e); } return details; }
From source file:org.generationcp.middleware.dao.gdms.MappingPopDAO.java
License:Open Source License
@SuppressWarnings("rawtypes") public List<MappingValueElement> getMappingValuesByGidAndMarkerIds(List<Integer> gids, List<Integer> markerIds) throws MiddlewareQueryException { List<MappingValueElement> mappingValues = new ArrayList<MappingValueElement>(); if (gids == null || gids.isEmpty() || markerIds == null || markerIds.isEmpty()) { return mappingValues; }/*w w w. ja v a2 s . c o m*/ SQLQuery query = this.getSession().createSQLQuery(MappingPopDAO.GET_MAPPING_VALUES_BY_GIDS_AND_MARKER_IDS); query.setParameterList("markerIdList", markerIds); query.setParameterList("gidList", gids); try { List results = query.list(); for (Object o : results) { Object[] result = (Object[]) o; if (result != null) { Integer datasetId = (Integer) result[0]; String mappingPopType = (String) result[1]; Integer parentAGid = (Integer) result[2]; Integer parentBGid = (Integer) result[3]; Integer gid = (Integer) result[4]; Integer markerId = (Integer) result[5]; String markerType = (String) result[6]; Integer markerSampleId = (Integer) result[7]; Integer accSampleId = (Integer) result[8]; MappingValueElement mappingValueElement = new MappingValueElement(datasetId, mappingPopType, parentAGid, parentBGid, gid, markerId, markerType, markerSampleId, accSampleId); mappingValues.add(mappingValueElement); } } return mappingValues; } catch (HibernateException e) { this.logAndThrowException("Error with getMappingValuesByGidAndMarkerIds(gids=" + gids + ", markerIds=" + markerIds + ") query from MappingPop: " + e.getMessage(), e); } return mappingValues; }