Example usage for org.hibernate SQLQuery setDouble

List of usage examples for org.hibernate SQLQuery setDouble

Introduction

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

Prototype

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

Source Link

Document

Bind a positional double-valued parameter.

Usage

From source file:com.bookselling.dao.SellingPostDaoImpl.java

@Override
public void autoDeny() {
    SQLQuery sqlQuery = getSession().createSQLQuery("update sellingpost as slp"
            + "   join post as p on slp.id = p.id " + "set status = 'DENY' "
            + "where TIMESTAMPDIFF(MINUTE, createdDate, NOW()) >= :time*60 and " + "      slp.status = 'WAIT'");
    sqlQuery.setDouble("time", timeToDeny).executeUpdate();
}

From source file:com.thoughtworks.go.server.persistence.PipelineRepository.java

License:Apache License

public static int updateNaturalOrderForPipeline(Session session, Long pipelineId, double naturalOrder) {
    String sql = "UPDATE pipelines SET naturalOrder = :naturalOrder WHERE id = :pipelineId";
    SQLQuery query = session.createSQLQuery(sql);
    query.setLong("pipelineId", pipelineId);
    query.setDouble("naturalOrder", naturalOrder);
    return query.executeUpdate();
}

From source file:edu.uiowa.icts.bluebutton.dao.LabTestHome.java

License:Apache License

private List<LoincCode> labTestQuery(String sex, Double age, String loincCodeCsvList) {
    List<LoincCode> list = new ArrayList<LoincCode>();
    if (sex != null && sex.length() > 0 && age != null) {
        sex = sex.substring(0, 1).toUpperCase();

        String sql = "select loinc_code as \"loinc_code\", min_normal as \"min_normal\", max_normal as \"max_normal\""
                + "   from bluebutton.lab_test lt, bluebutton.lab_test_range ltr "
                + "   where lt.lab_test_id = ltr.lab_test_id " + "   and ltr.sex like :sex "
                + "   and :age >= ltr.min_age_years  " + "   and :age < ltr.max_age_years "
                + "   and loinc_code IS NOT NULL ";
        if (loincCodeCsvList != null) {
            sql += "and loinc_code in (:loincCodeCsvList) ";
        }/*from   w  w w . j a  v a2 s.c  o  m*/
        SQLQuery query = this.sessionFactory.getCurrentSession().createSQLQuery(sql);
        query.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);
        query.setString("sex", "%" + sex + "%");
        query.setDouble("age", age);
        if (loincCodeCsvList != null) {
            query.setParameterList("loincCodeCsvList", loincCodeCsvList.split(","));
        }
        List data = query.list();

        for (Object object : data) {
            Map row = (Map) object;
            LoincCode lc = new LoincCode(row.get("loinc_code").toString(),
                    new Double((double) row.get("min_normal")), new Double((double) row.get("max_normal")));
            list.add(lc);
        }
    }
    return list;
}

From source file:ubic.gemma.persistence.service.expression.experiment.ExpressionExperimentDaoImpl.java

License:Apache License

@Override
public Collection<ExpressionExperiment> findByExpressedGene(Gene gene, Double rank) {

    //language=MySQL
    final String queryString = "SELECT DISTINCT ee.ID AS eeID FROM "
            + "GENE2CS g2s, COMPOSITE_SEQUENCE cs, PROCESSED_EXPRESSION_DATA_VECTOR dedv, INVESTIGATION ee "
            + "WHERE g2s.CS = cs.ID AND cs.ID = dedv.DESIGN_ELEMENT_FK AND dedv.EXPRESSION_EXPERIMENT_FK = ee.ID"
            + " AND g2s.gene = :geneID AND dedv.RANK_BY_MEAN >= :rank";

    Collection<Long> eeIds;

    try {//ww w .  j a  v  a 2s  . c o m
        Session session = this.getSessionFactory().getCurrentSession();
        org.hibernate.SQLQuery queryObject = session.createSQLQuery(queryString);
        queryObject.setLong("geneID", gene.getId());
        queryObject.setDouble("rank", rank);
        queryObject.addScalar("eeID", new LongType());
        ScrollableResults results = queryObject.scroll();

        eeIds = new HashSet<>();

        // Post Processing
        while (results.next())
            eeIds.add(results.getLong(0));

        session.clear();
    } catch (org.hibernate.HibernateException ex) {
        throw super.convertHibernateAccessException(ex);
    }

    return this.load(eeIds);
}