Example usage for org.hibernate Query setBoolean

List of usage examples for org.hibernate Query setBoolean

Introduction

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

Prototype

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

Source Link

Document

Bind a named boolean-valued parameter.

Usage

From source file:com.openkm.extension.dao.ProposedQueryDAO.java

License:Open Source License

/**
 * Mark proposed as accepted/*from  w  ww  .j a v  a 2 s.c  o m*/
 */
public static void markAccepted(long pqId) throws DatabaseException {
    log.debug("markAccepted({})", pqId);
    String qs = "update ProposedQueryReceived ps set ps.accepted=:accepted where ps.id=:id";
    Session session = null;

    try {
        session = HibernateUtil.getSessionFactory().openSession();
        Query q = session.createQuery(qs);
        q.setLong("id", pqId);
        q.setBoolean("accepted", true);
        q.executeUpdate();
        log.debug("markAccepted: void");
    } catch (HibernateException e) {
        throw new DatabaseException(e.getMessage(), e);
    } finally {
        HibernateUtil.close(session);
    }
}

From source file:com.openkm.extension.dao.ProposedSubscriptionDAO.java

License:Open Source License

/**
 * Mark proposed as accepted//from   w w  w  .  j  a  v a2  s .c o  m
 */
public static void markAccepted(int psId) throws DatabaseException {
    log.debug("markAccepted({})", psId);
    String qs = "update ProposedSubscriptionReceived ps set ps.accepted=:accepted where ps.id=:id";
    Session session = null;

    try {
        session = HibernateUtil.getSessionFactory().openSession();
        Query q = session.createQuery(qs);
        q.setInteger("id", psId);
        q.setBoolean("accepted", true);
        q.executeUpdate();
        log.debug("markAccepted: void");
    } catch (HibernateException e) {
        throw new DatabaseException(e.getMessage(), e);
    } finally {
        HibernateUtil.close(session);
    }
}

From source file:com.openkm.extension.dao.StampImageDAO.java

License:Open Source License

/**
 * Active/*w ww. j  a va 2  s.c  o  m*/
 */
public static void active(int siId, boolean active) throws DatabaseException {
    log.debug("active({}, {})", siId, active);
    String qs = "update StampImage si set si.active=:active where si.id=:id";
    Session session = null;
    Transaction tx = null;

    try {
        session = HibernateUtil.getSessionFactory().openSession();
        tx = session.beginTransaction();
        Query q = session.createQuery(qs);
        q.setBoolean("active", active);
        q.setInteger("id", siId);
        q.executeUpdate();
        HibernateUtil.commit(tx);
    } catch (HibernateException e) {
        HibernateUtil.rollback(tx);
        throw new DatabaseException(e.getMessage(), e);
    } finally {
        HibernateUtil.close(session);
    }

    log.debug("active: void");
}

From source file:com.openkm.extension.dao.StampImageDAO.java

License:Open Source License

/**
 * Find by user//from w  w  w .  ja va2  s. c o  m
 */
@SuppressWarnings("unchecked")
public static List<StampImage> findByUser(String usrId) throws DatabaseException {
    log.debug("findByUser({})", usrId);
    String qs = "from StampImage si where :user in elements(si.users)" + "and si.active=:active order by si.id";
    Session session = null;

    try {
        session = HibernateUtil.getSessionFactory().openSession();
        Query q = session.createQuery(qs);
        q.setString("user", usrId);
        q.setBoolean("active", true);
        List<StampImage> ret = q.list();
        log.debug("findByUser: {}", ret);
        return ret;
    } catch (HibernateException e) {
        throw new DatabaseException(e.getMessage(), e);
    } finally {
        HibernateUtil.close(session);
    }
}

From source file:com.openkm.extension.dao.StampTextDAO.java

License:Open Source License

/**
 * Active/*w ww. java2s.  c  om*/
 */
public static void active(int stId, boolean active) throws DatabaseException {
    log.debug("active({}, {})", stId, active);
    String qs = "update StampText st set st.active=:active where st.id=:id";
    Session session = null;
    Transaction tx = null;

    try {
        session = HibernateUtil.getSessionFactory().openSession();
        tx = session.beginTransaction();
        Query q = session.createQuery(qs);
        q.setBoolean("active", active);
        q.setInteger("id", stId);
        q.executeUpdate();
        HibernateUtil.commit(tx);
    } catch (HibernateException e) {
        HibernateUtil.rollback(tx);
        throw new DatabaseException(e.getMessage(), e);
    } finally {
        HibernateUtil.close(session);
    }

    log.debug("active: void");
}

From source file:com.openkm.extension.dao.StampTextDAO.java

License:Open Source License

/**
 * Find by user// ww w. jav  a 2s  .  com
 */
@SuppressWarnings("unchecked")
public static List<StampText> findByUser(String usrId) throws DatabaseException {
    log.debug("findByUser({})", usrId);
    String qs = "from StampText st where :user in elements(st.users)" + "and st.active=:active order by st.id";
    Session session = null;

    try {
        session = HibernateUtil.getSessionFactory().openSession();
        Query q = session.createQuery(qs);
        q.setString("user", usrId);
        q.setBoolean("active", true);
        List<StampText> ret = q.list();
        log.debug("findByUser: {}", ret);
        return ret;
    } catch (HibernateException e) {
        throw new DatabaseException(e.getMessage(), e);
    } finally {
        HibernateUtil.close(session);
    }
}

From source file:com.qcadoo.model.internal.search.SearchQueryImpl.java

License:Open Source License

@Override
public void addParameters(final Query query) {
    for (Map.Entry<String, String> parameter : strings.entrySet()) {
        query.setString(parameter.getKey(), parameter.getValue());
    }/*from  w  ww.  j  a  v  a 2s.  co m*/
    for (Map.Entry<String, Boolean> parameter : booleans.entrySet()) {
        query.setBoolean(parameter.getKey(), parameter.getValue());
    }
    for (Map.Entry<String, Byte> parameter : bytes.entrySet()) {
        query.setByte(parameter.getKey(), parameter.getValue());
    }
    for (Map.Entry<String, Short> parameter : shorts.entrySet()) {
        query.setShort(parameter.getKey(), parameter.getValue());
    }
    for (Map.Entry<String, Integer> parameter : integers.entrySet()) {
        query.setInteger(parameter.getKey(), parameter.getValue());
    }
    for (Map.Entry<String, Long> parameter : longs.entrySet()) {
        query.setLong(parameter.getKey(), parameter.getValue());
    }
    for (Map.Entry<String, Float> parameter : floats.entrySet()) {
        query.setFloat(parameter.getKey(), parameter.getValue());
    }
    for (Map.Entry<String, Double> parameter : doubles.entrySet()) {
        query.setDouble(parameter.getKey(), parameter.getValue());
    }
    for (Map.Entry<String, BigDecimal> parameter : bigDecimals.entrySet()) {
        query.setBigDecimal(parameter.getKey(), parameter.getValue());
    }
    for (Map.Entry<String, Date> parameter : dates.entrySet()) {
        query.setDate(parameter.getKey(), parameter.getValue());
    }
    for (Map.Entry<String, Date> parameter : times.entrySet()) {
        query.setTime(parameter.getKey(), parameter.getValue());
    }
    for (Map.Entry<String, Date> parameter : timestamps.entrySet()) {
        query.setTimestamp(parameter.getKey(), parameter.getValue());
    }
    for (Map.Entry<String, Object> parameter : parameters.entrySet()) {
        query.setParameter(parameter.getKey(), parameter.getValue());
    }
    for (Map.Entry<String, Collection<? extends Object>> parametersList : parameterLists.entrySet()) {
        query.setParameterList(parametersList.getKey(), parametersList.getValue());
    }
    for (Map.Entry<String, Object> parameter : entities.entrySet()) {
        query.setEntity(parameter.getKey(), parameter.getValue());
    }
}

From source file:com.slambook.repository.implementation.FriendsDAOImpl.java

@Override
public ArrayList getUserFriends(long userId) {

    Query query = sessionFactory.getCurrentSession().getNamedQuery("Friends.getUserFriends");
    query.setLong("userId", userId);
    query.setBoolean("allow", true);
    return (ArrayList) query.list();
}

From source file:com.sos.jobnet.db.JobNetPlanDBLayer.java

License:Apache License

private Query setQueryParams(String hql) {
    Query query = session.createQuery(hql);

    if (filter.getPlannedStartTimeFrom() != null && !filter.getPlannedStartTimeFrom().equals("")) {
        query.setTimestamp(PLANNED_START_TIME_FROM, filter.getPlannedStartTimeFrom());
    }// w w  w .  ja va  2 s  .co  m

    if (filter.getPlannedStartTimeTo() != null && !filter.getPlannedStartTimeTo().equals("")) {
        query.setTimestamp(PLANNED_START_TIME_TO, filter.getPlannedStartTimeTo());
    }

    if (filter.getStartTimeFrom() != null && !filter.getStartTimeFrom().equals("")) {
        query.setTimestamp(START_TIME_FROM, filter.getStartTimeFrom());
    }

    if (filter.getStartTimeTo() != null && !filter.getStartTimeTo().equals("")) {
        query.setTimestamp(START_TIME_TO, filter.getStartTimeTo());
    }

    if (filter.getSchedulerId() != null && !filter.getSchedulerId().equals("")) {
        query.setParameter(SCHEDULER_ID, filter.getSchedulerId());
    }

    if (filter.getUuid() != null && !filter.getUuid().equals("")) {
        query.setParameter(UUID, filter.getUuid());
    }

    if (filter.getNode() != null && !filter.getNode().equals("")) {
        query.setParameter(NODE, filter.getNode());
    }

    if (filter.getNodeId() != null) {
        query.setLong(NODE_ID, filter.getNodeId());
    }

    if (filter.getSubnetId() != null) {
        query.setLong(SUBNET_ID, filter.getSubnetId());
    }

    if (filter.getConnectorId() != null) {
        query.setLong(CONNECTOR_ID, filter.getConnectorId());
    }

    if (filter.getNodeType() != null) {
        query.setParameter(NODE_TYPE, filter.getNodeType());
    }

    if (filter.getPlanId() != null) {
        query.setLong(PLAN_ID, filter.getPlanId());
    }

    if (filter.getJobnet() != null && !filter.getJobnet().equals("")) {
        query.setParameter(JOBNET, filter.getJobnet());
    }

    if (filter.getStatus() != null && !filter.getStatus().equals("")) {
        query.setInteger(STATUS, filter.getStatus());
    }

    if (filter.getStatusWaiter() != null && !filter.getStatusWaiter().equals("")) {
        query.setInteger(STATUS_WAITER, filter.getStatusWaiter());
    }

    if (filter.getStatusRunner() != null && !filter.getStatusRunner().equals("")) {
        query.setInteger(STATUS_RUNNER, filter.getStatusRunner());
    }

    if (filter.getStatusDispatcher() != null && !filter.getStatusDispatcher().equals("")) {
        query.setInteger(STATUS_DISPATCHER, filter.getStatusDispatcher());
    }

    if (filter.getIsWaiterSkipped() != null) {
        query.setBoolean(IS_WAITER_SKIPPED, filter.getIsWaiterSkipped());
    }

    if (filter.getIsRunnerOnDemand() != null) {
        query.setBoolean(IS_RUNNER_ON_DEMAND, filter.getIsRunnerOnDemand());
    }

    if (filter.getIsRunnerSkipped() != null) {
        query.setBoolean(IS_RUNNER_SKIPPED, filter.getIsRunnerSkipped());
    }

    if (filter.getBootstrap() != null) {
        query.setBoolean(BOOTSTRAP, filter.getBootstrap());
    }

    if (filter.getIsDispatcherSkipped() != null) {
        query.setBoolean(IS_DISPATCHER_SKIPPED, filter.getIsDispatcherSkipped());
    }

    return query;

}

From source file:com.square.adherent.noyau.dao.implementations.prestation.RelevePrestationDaoImpl.java

License:Open Source License

@Override
@SuppressWarnings("unchecked")
public List<RelevePrestation> getListeReleveParCriteres(
        CritereSelectionRelevePrestationDto critereSelectionRelevePrestationDto, Boolean triDesc) {
    final StringBuffer requete = new StringBuffer(
            "select distinct(relevePresta) from RelevePrestation relevePresta ");
    boolean existCritere = false;
    if (critereSelectionRelevePrestationDto.getIdPersonne() != null) {
        requete.append("where relevePresta.uidPersonne =:idPersonne ");
        existCritere = true;/*from w  w w  .ja v  a2 s.  co  m*/
    }
    if (critereSelectionRelevePrestationDto.getRelevePrestationId() != null) {
        requete.append(getConditionSeparator(existCritere)).append("relevePresta.id =:idRelevePresta ");
        existCritere = true;
    }
    if (critereSelectionRelevePrestationDto.getEnvoyeMail() != null) {
        requete.append(getConditionSeparator(existCritere))
                .append("relevePresta.envoyeMail =:envoyeMailParam ");
        existCritere = true;
    }
    if (critereSelectionRelevePrestationDto.getAutorisationEnvoiMail() != null) {
        requete.append(getConditionSeparator(existCritere))
                .append("relevePresta.moyenPaiement.autorisationEnvoiMail = :autorisationEnvoiMailParam ");
        existCritere = true;
    }
    if (critereSelectionRelevePrestationDto.getDateMaxImpression() != null) {
        requete.append(getConditionSeparator(existCritere))
                .append("relevePresta.dateImpression <= :dateMaxImpressionParam ");
        existCritere = true;
    }
    if (critereSelectionRelevePrestationDto.getDateMinImpression() != null) {
        requete.append(getConditionSeparator(existCritere))
                .append("relevePresta.dateImpression >= :dateMinImpressionParam ");
        existCritere = true;
    }
    if (triDesc != null && triDesc) {
        requete.append("order by relevePresta.dateImpression desc");
    } else if (triDesc != null && !triDesc) {
        requete.append("order by relevePresta.dateImpression asc");
    }

    final Query query = createQuery(requete.toString());
    query.setFirstResult(0);
    if (critereSelectionRelevePrestationDto.getNombreMax() != null) {
        query.setMaxResults(critereSelectionRelevePrestationDto.getNombreMax().intValue());
    }

    if (critereSelectionRelevePrestationDto.getIdPersonne() != null) {
        query.setLong("idPersonne", critereSelectionRelevePrestationDto.getIdPersonne());
    }
    if (critereSelectionRelevePrestationDto.getRelevePrestationId() != null) {
        query.setLong("idRelevePresta", critereSelectionRelevePrestationDto.getRelevePrestationId());
    }
    if (critereSelectionRelevePrestationDto.getEnvoyeMail() != null) {
        query.setBoolean("envoyeMailParam", critereSelectionRelevePrestationDto.getEnvoyeMail().booleanValue());
    }
    if (critereSelectionRelevePrestationDto.getAutorisationEnvoiMail() != null) {
        query.setBoolean("autorisationEnvoiMailParam",
                critereSelectionRelevePrestationDto.getAutorisationEnvoiMail().booleanValue());
    }
    if (critereSelectionRelevePrestationDto.getDateMaxImpression() != null) {
        query.setCalendar("dateMaxImpressionParam", critereSelectionRelevePrestationDto.getDateMaxImpression());
    }
    if (critereSelectionRelevePrestationDto.getDateMinImpression() != null) {
        query.setCalendar("dateMinImpressionParam", critereSelectionRelevePrestationDto.getDateMinImpression());
    }
    return (List<RelevePrestation>) query.list();
}