Example usage for org.hibernate Query setDouble

List of usage examples for org.hibernate Query setDouble

Introduction

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

Prototype

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

Source Link

Document

Bind a named double-valued parameter.

Usage

From source file:de.xwic.sandbox.server.installer.DirectQuery.java

License:Apache License

/**
 * @param query/*from  w w w.j av a2  s  .  c o m*/
 * @param params
 */
private static void setParams(Query query, Object... params) {
    if (null != params) {
        for (int i = 0; i < params.length; i++) {
            if (params[i] instanceof String) {
                query.setString(i, (String) params[i]);
            } else if (params[i] instanceof Integer) {
                query.setInteger(i, (Integer) params[i]);
            } else if (params[i] instanceof Double) {
                query.setDouble(i, (Double) params[i]);
            } else if (params[i] instanceof Date) {
                query.setTimestamp(i, (Date) params[i]);
            } else {
                throw new IllegalArgumentException("Param type not supported #" + i);
            }
        }
    }
}

From source file:es.sm2.openppm.core.dao.ProjectDAO.java

License:Open Source License

/**
 * Update BAC//from  w  ww  .  j a  v a  2 s.  c  om
 *
 * @param project
 */
public synchronized void updateBAC(Project project) {

    Query query = getSession()
            .createQuery("update Project p " + " set p.bac = :bac" + " where p.idProject = :idProject");

    query.setInteger("idProject", project.getIdProject());
    query.setDouble("bac", project.getBac());
    query.executeUpdate();
}

From source file:models.BalanceSheetSummary.java

public void update(Integer ref, Double total) {
    Session session;/*from  ww  w .  j  a  v a2s.  com*/
    session = DatabaseUtil.getSessionFactory().openSession();
    Transaction tx = null;
    try {
        tx = session.beginTransaction();
        String hql = "update BalanceSheetSummaries " + "set total = :total " + "where ref = :ref";
        Query query = session.createQuery(hql);
        query.setDouble("total", total);
        query.setInteger("ref", ref);
        System.out.println(query.executeUpdate());
        session.flush();
        tx.commit();
    } catch (HibernateException ex) {
        System.out.println(ex.getMessage());
        if (tx != null) {
            tx.rollback();
        }
    } finally {
        session.close();
    }
}

From source file:models.ProfitLossStandardSummary.java

public void update(Integer ref, Double totalThisMonth, Double totalUntilMonth) {
    Session session;// ww  w .  ja  v  a  2  s.  co m
    session = DatabaseUtil.getSessionFactory().openSession();
    Transaction tx = null;
    try {
        tx = session.beginTransaction();
        String hql = "update ProfitLossStandardSummaries " + "set totalThisMonth = :totalThisMonth, "
                + "totalUntilMonth = :totalUntilMonth " + "where ref = :ref";
        Query query = session.createQuery(hql);
        query.setDouble("totalThisMonth", totalThisMonth);
        query.setDouble("totalUntilMonth", totalUntilMonth);
        query.setInteger("ref", ref);
        System.out.println(query.executeUpdate());
        session.flush();
        tx.commit();
    } catch (HibernateException ex) {
        System.out.println(ex.getMessage());
        if (tx != null) {
            tx.rollback();
        }
    } finally {
        session.close();
    }
}

From source file:net.mlw.vlh.adapter.hibernate3.util.setter.DoubleSetter.java

License:Open Source License

/**
 * @see net.mlw.vlh.adapter.hibernate3.util.Setter#set(Query, String, Object)
 *///from ww w.  j  ava2s .  c om
public void set(Query query, String key, Object value) throws HibernateException, ParseException {
    if (value instanceof Double) {
        if (LOGGER.isInfoEnabled()) {
            LOGGER.info("The key='" + key + "'s value is instance of a Double, now is converting to double.");
        }
        double doubleValue = ((Double) value).doubleValue();
        query.setDouble(key, doubleValue);
    } else if (value instanceof String) {
        if (LOGGER.isInfoEnabled()) {
            LOGGER.info("The key='" + key + "'s value is instance of a String, now is parsing to double.");
        }
        double doubleValue = Double.parseDouble((String) value);
        query.setDouble(key, doubleValue);
    } else if (value == null) {
        if (LOGGER.isInfoEnabled()) {
            LOGGER.info("The key='" + key + "'s value is null.");
        }
        query.setParameter(key, null);
    } else {
        throw new IllegalArgumentException(
                "Cannot convert value of class " + value.getClass().getName() + " to double (key=" + key + ")");
    }
}

From source file:org.apache.ctakes.ytex.kernel.dao.ClassifierEvaluationDaoImpl.java

License:Apache License

private Query prepareUniqueFeatureEvalQuery(String corpusName, String featureSetName, String label,
        String evaluationType, Integer foldId, Double param1, String param2, String queryName) {
    Query q = this.sessionFactory.getCurrentSession().getNamedQuery(queryName);
    q.setString("corpusName", nullToEmptyString(corpusName));
    q.setString("featureSetName", nullToEmptyString(featureSetName));
    q.setString("label", nullToEmptyString(label));
    q.setString("evaluationType", evaluationType);
    q.setDouble("param1", param1 == null ? 0 : param1);
    q.setString("param2", nullToEmptyString(param2));
    q.setInteger("crossValidationFoldId", foldId == null ? 0 : foldId);
    return q;/*w ww . j  a  v a 2  s.  c  om*/
}

From source file:org.apache.ctakes.ytex.kernel.dao.ClassifierEvaluationDaoImpl.java

License:Apache License

@SuppressWarnings("unchecked")
@Override/*w ww . j a  v a 2  s  . c  om*/
public List<FeatureRank> getThresholdFeatures(String corpusName, String featureSetName, String label,
        String evaluationType, Integer foldId, double param1, String param2, double evaluationThreshold) {
    Query q = prepareUniqueFeatureEvalQuery(corpusName, featureSetName, label, evaluationType, foldId, param1,
            param2, "getThresholdFeatures");
    q.setDouble("evaluation", evaluationThreshold);
    return q.list();
}

From source file:org.apache.ctakes.ytex.kernel.dao.KernelEvaluationDaoImpl.java

License:Apache License

public KernelEvaluation getKernelEval(String name, String experiment, String label, int foldId, double param1,
        String param2) {//w w  w . ja va  2s .  c  om
    Query q = this.getSessionFactory().getCurrentSession().getNamedQuery("getKernelEval");
    q.setString("corpusName", name);
    q.setString("experiment", DBUtil.nullToEmptyString(experiment));
    q.setString("label", DBUtil.nullToEmptyString(label));
    q.setInteger("foldId", foldId);
    q.setDouble("param1", param1);
    q.setString("param2", DBUtil.nullToEmptyString(param2));
    return (KernelEvaluation) q.uniqueResult();
}

From source file:org.archiviststoolkit.mydomain.DigitalObjectDAO.java

License:Open Source License

public void updateFromDrop(Long resourceComponentId, Long resourceParentId, Long resourceComponentParentId,
        Double componentOrder) {/* ww w .  ja  v a  2 s  .c  o  m*/

    Session session = SessionFactory.getInstance().openSession();
    Query query = session.getNamedQuery("updateFromDrop");
    query.setLong("resourceComponentId", resourceComponentId);
    if (resourceParentId == null) {
        query.setLong("resourceId", 0l);
    } else {
        query.setLong("resourceId", resourceParentId);
    }
    if (resourceComponentParentId == null) {
        query.setLong("parentResourceComponentId", 0l);
    } else {
        query.setLong("parentResourceComponentId", resourceComponentParentId);
    }
    query.setDouble("resourcesOrder", componentOrder);
    query.list();
    session.close();
}

From source file:org.jbpm.db.GraphSession.java

License:Open Source License

public List calculateAverageTimeByNode(final long processDefinitionId, final long minumumDurationMillis) {
    List results = null;/*from   w ww . j a  v a2s .c  om*/
    try {
        Query query = session.getNamedQuery("GraphSession.calculateAverageTimeByNode");
        query.setLong("processDefinitionId", processDefinitionId);
        query.setDouble("minimumDuration", minumumDurationMillis);
        List listResults = query.list();

        if (listResults != null) {
            results = new ArrayList();
            Iterator iter = listResults.iterator();
            while (iter.hasNext()) {
                Object[] values = (Object[]) iter.next();

                AverageNodeTimeEntry averageNodeTimeEntry = new AverageNodeTimeEntry();
                averageNodeTimeEntry.setNodeId(((Number) values[0]).longValue());
                averageNodeTimeEntry.setNodeName((String) values[1]);
                averageNodeTimeEntry.setCount(((Number) values[2]).intValue());
                averageNodeTimeEntry.setAverageDuration(((Number) values[3]).longValue());
                averageNodeTimeEntry.setMinDuration(((Number) values[4]).longValue());
                averageNodeTimeEntry.setMaxDuration(((Number) values[5]).longValue());

                results.add(averageNodeTimeEntry);
            }
        }
    } catch (Exception e) {
        log.error(e);
        jbpmSession.handleException();
        throw new JbpmException(
                "couldn't load process instances for process definition '" + processDefinitionId + "'", e);
    }
    return results;
}