Example usage for org.hibernate SQLQuery setFloat

List of usage examples for org.hibernate SQLQuery setFloat

Introduction

In this page you can find the example usage for org.hibernate SQLQuery setFloat.

Prototype

@Deprecated
@SuppressWarnings("unchecked")
default Query<R> setFloat(int position, float val) 

Source Link

Document

Bind a positional float-valued parameter.

Usage

From source file:org.generationcp.middleware.dao.gdms.MapDAO.java

License:Open Source License

public List<MapInfo> getMapInfoByMapChromosomeAndPosition(final Integer mapId, final String chromosome,
        final Float startPosition) {
    final SQLQuery query = this.getSession().createSQLQuery(MapDAO.GET_MAP_INFO_BY_MAP_CHROMOSOME_AND_POSITION);
    query.setInteger("mapId", mapId);
    query.setString("chromosome", chromosome);
    query.setFloat("startPosition", startPosition);

    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("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  om*/
        @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 String linkageGroup = (String) result[4];
                final String mapUnit = (String) result[5];

                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 getMapInfoByMapChromosomeAndPosition() query: " + e.getMessage(), e);
    }

    return mapInfoList;
}