Example usage for javax.persistence Query setParameter

List of usage examples for javax.persistence Query setParameter

Introduction

In this page you can find the example usage for javax.persistence Query setParameter.

Prototype

Query setParameter(int position, Object value);

Source Link

Document

Bind an argument value to a positional parameter.

Usage

From source file:pdsanchez.mywebtools.model.dao.jpa.ToolDAOJPAImpl.java

@Override
public List<Tool> findAll(Category category) {
    Query q = getEntityManager()
            .createQuery("select o from Tool o where lower(o.category.categoryName) = :name and o.isvalid = 1");
    q.setParameter("name", category.getCategoryName().toLowerCase());
    return q.getResultList();
}

From source file:be.fedict.eid.pkira.blm.model.contracts.ContractQuery.java

private void addQueryParameters(String userRrn, ContractsFilter contractsFilter, Query query) {
    query.setParameter("nationalRegisterNumber", userRrn);
    query.setParameter("registrationStatus", RegistrationStatus.APPROVED);
    if (contractsFilter.getCertificateDomainId() != null)
        query.setParameter("certificateDomainId", contractsFilter.getCertificateDomainId());
    if ((contractsFilter.isIncludeRequestContracts() || !contractsFilter.isIncludeRevocationContracts())
            && contractsFilter.getCertificateType() != null)
        query.setParameter("certificateType", contractsFilter.getCertificateType());
    if (isNotBlank(contractsFilter.getRequesterName()))
        query.setParameter("requesterName", "%" + contractsFilter.getRequesterName().toLowerCase() + "%");
    if (isNotBlank(contractsFilter.getDnExpression()))
        query.setParameter("dnExpression", "%" + contractsFilter.getDnExpression().toLowerCase() + "%");
    if (contractsFilter.getCreationDateFrom() != null)
        query.setParameter("creationDateFrom", contractsFilter.getCreationDateFrom());
    if (contractsFilter.getCreationDateTo() != null)
        query.setParameter("creationDateTo", contractsFilter.getCreationDateTo());
    if (isNotBlank(contractsFilter.getResultMessage()))
        query.setParameter("resultMessage", "%" + contractsFilter.getResultMessage().toLowerCase() + "%");
}

From source file:com.srinathavan.mwbng.core.repositories.jpa.JpaBlogRepo.java

@Override
public List<Blog> findBlogsByAccount(Long accountId) {
    Query query = em.createQuery("Select b from Blog b where b.owner.id=?");
    query.setParameter(0, accountId);
    return query.getResultList();
}

From source file:com.expressui.sample.dao.StateDao.java

public List<State> findByCountry(Country country) {
    Query query = getEntityManager()
            .createQuery("SELECT s FROM State s WHERE s.country = :country ORDER BY s.name");
    query.setParameter("country", country);
    setReadOnly(query);/*from  w ww .ja v  a  2s . co  m*/

    return query.getResultList();
}

From source file:de.alpharogroup.phone.data.management.system.service.SlotScoresBusinessService.java

@Override
@SuppressWarnings("unchecked")
public List<SlotScores> find(final String phoneNumber, final Integer score) {
    final String hqlString = HqlStringCreator.forSlotScore(phoneNumber, score);
    final Query query = getQuery(hqlString);
    if ((phoneNumber != null) && !phoneNumber.isEmpty()) {
        query.setParameter("phoneNumber", phoneNumber);
    }//ww w  .  j a  va  2  s . c  o  m
    if (score != null) {
        query.setParameter("score", score);
    }
    final List<SlotScores> images = query.getResultList();
    return images;
}

From source file:org.messic.server.datamodel.jpaimpl.DAOJPAPlaylist.java

@Override
@Transactional//from w  ww  .  j a v  a  2  s.  com
public List<MDOPlaylist> getAll(String username) {
    Query query = entityManager.createQuery("from MDOPlaylist as a where (a.owner.login = :userName)");
    query.setParameter("userName", username);

    @SuppressWarnings("unchecked")
    List<MDOPlaylist> results = query.getResultList();
    return results;
}

From source file:com.brienwheeler.svc.users.impl.UserEmailAddressDao.java

@Override
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
@SuppressWarnings("unchecked")
public List<UserEmailAddress> findByUser(User user) {
    Query query = entityManager
            .createQuery("from UserEmailAddress where user = :user order by emailAddress.address");
    query.setParameter("user", user);
    return (List<UserEmailAddress>) query.getResultList();
}

From source file:com.june.app.site.repository.jpa.VideoRepositoryImpl.java

@Override
public Video videoGet(Integer nttId) {
    Query query = this.em.createQuery("SELECT video FROM Video video WHERE video.nttId =:nttId");
    query.setParameter("nttId", nttId);
    return (Video) query.getSingleResult();
}

From source file:com.ebiz.modules.persistence.repository.support.MyRepositoryImpl.java

@Override
@Transactional//from  ww w  . jav  a 2s  . c  o m
public void delete(ID[] ids) {
    logger.trace("----->MyRepositoryImpl.delete(ID[] ids)");
    String qlString;
    Class<T> clazz = ei.getJavaType();
    if (clazz.isAnnotationPresent(LogicallyDelete.class)) {
        LogicallyDelete logicallyDelete = clazz.getAnnotation(LogicallyDelete.class);
        Object value = ConvertUtils.convert(logicallyDelete.value(), logicallyDelete.type().getClazz());
        qlString = String.format(STATE_DELETE_QUERY_STRING, ei.getEntityName(), logicallyDelete.name(), value);
    } else {
        qlString = String.format(DELETE_QUERY_STRING, ei.getEntityName());
    }
    logger.debug("......qlString:={}", qlString);
    Query query = em.createQuery(qlString);
    query.setParameter(1, Arrays.asList(ids));
    query.executeUpdate();
}

From source file:com.telefonica.euro_iaas.paasmanager.dao.impl.EnvironmentDaoJpaImpl.java

public List<Environment> findByOrgAndVdc(String org, String vdc) {

    List list;//from  w w w .  j  av a  2 s  .co m
    String queryString = "SELECT e FROM Environment e WHERE e.org LIKE :orgName and e.vdc = :vdcName";
    Query query = getEntityManager().createQuery(queryString);

    list = query.setParameter("orgName", org).setParameter("vdcName", vdc).getResultList();

    return list;
}