Example usage for javax.persistence TypedQuery setParameter

List of usage examples for javax.persistence TypedQuery setParameter

Introduction

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

Prototype

TypedQuery<X> setParameter(int position, Object value);

Source Link

Document

Bind an argument value to a positional parameter.

Usage

From source file:com.deltastar.task7.core.repository.api.impl.FundRepositoryImpl.java

@Override
public List<Fund> findFundByFundNameOrSymbol(String fundName, String symbol) {
    TypedQuery<Fund> query = entityManager.createNamedQuery("findFundByFundNameOrSymbol", Fund.class);
    query.setParameter("p_symbol", "%" + symbol + "%");
    query.setParameter("p_fundName", "%" + fundName + "%");
    return query.getResultList();
}

From source file:org.openmeetings.app.data.basic.dao.SOAPLoginDaoImpl.java

public SOAPLogin getSOAPLoginByHash(String hash) {
    try {/*from   ww  w  . ja  v a 2 s  . c om*/
        String hql = "select sl from SOAPLogin as sl " + "WHERE sl.hash LIKE :hash";
        TypedQuery<SOAPLogin> query = em.createQuery(hql, SOAPLogin.class);
        query.setParameter("hash", hash);
        List<SOAPLogin> sList = query.getResultList();

        if (sList.size() > 1) {
            throw new Exception("there are more then one SOAPLogin with identical hash! " + hash);
        }

        if (sList.size() == 1) {
            return sList.get(0);
        }

    } catch (Exception ex2) {
        log.error("[getSOAPLoginByHash]: ", ex2);
    }
    return null;
}

From source file:com.deltastar.task7.core.repository.api.impl.CustomerRepositoryImpl.java

/**
 * {@inheritDoc}/*  w  w w.ja  va2s.c o m*/
 */
public Customer getCustomerByUserName(final String userName) {
    TypedQuery<Customer> query = entityManager.createNamedQuery("findCustomerByUserName", Customer.class);
    query.setParameter("p_userName", userName);
    List<Customer> customers = query.getResultList();
    return (customers != null && !customers.isEmpty()) ? customers.get(0) : null;
}

From source file:org.mitre.openid.connect.repository.impl.JpaUserInfoRepository.java

/**
 * Get a single UserInfo object by its username
 *//* w w w  .j  a va 2 s . c  om*/
@Override
public UserInfo getByUsername(String username) {
    TypedQuery<DefaultUserInfo> query = manager.createNamedQuery(DefaultUserInfo.QUERY_BY_USERNAME,
            DefaultUserInfo.class);
    query.setParameter(DefaultUserInfo.PARAM_USERNAME, username);

    return getSingleResult(query.getResultList());

}

From source file:com.deltastar.task7.core.repository.api.impl.TransitionRepositoryImpl.java

@Override
public List<Transition> getPendingTransitionList() {
    TypedQuery<Transition> query = entityManager.createNamedQuery("findTransitionByStatus", Transition.class);
    query.setParameter("p_status", CCConstants.TRAN_STATUS_PENDING);
    return query.getResultList();
}

From source file:com.expressui.sample.dao.query.OpportunityQuery.java

@Override
public void setParameters(TypedQuery<Serializable> typedQuery) {
    if (hasValue(accountName)) {
        typedQuery.setParameter("accountName", "%" + accountName.toUpperCase() + "%");
    }//from   w w  w.jav  a  2  s .  c  o  m
    if (hasValue(salesStages)) {
        typedQuery.setParameter("salesStages", salesStages);
    }
}

From source file:com.oreilly.springdata.jpa.core.JpaCustomerRepository.java

@Override
public Customer findByEmailAddress(EmailAddress emailAddress) {

    TypedQuery<Customer> query = em.createQuery("select c from Customer c where c.emailAddress = :email",
            Customer.class);
    query.setParameter("email", emailAddress);

    return query.getSingleResult();
}

From source file:com.beto.test.securityinterceptor.model.dao.generic.AbstractDao.java

public List<T> getListWithNamedQuery(String query, String inParamName, List<?> inList) throws Exception {

    try {/*from   www .  j a  va2  s  .  c o m*/
        TypedQuery<T> tq = getEntityManager().createNamedQuery(query, entityClass);
        tq.setParameter(inParamName, inList);
        return tq.getResultList();
    } catch (NoResultException e) {
        LOGGER.debug("NO DATA FOUND...");
    }
    return null;
}

From source file:com.deltastar.task7.core.repository.api.impl.FundPriceHistoryViewRepositoryImpl.java

@Override
public List<FundPriceHistoryView> getFundPriceHistoryViewListById(int fundId) {

    TypedQuery<FundPriceHistoryView> query = entityManager.createNamedQuery("findFundPriceHistoryByFundId",
            FundPriceHistoryView.class);
    query.setParameter("p_fundId", fundId);
    return query.getResultList();

}

From source file:com.expressui.sample.dao.query.ContactQuery.java

@Override
public void setParameters(TypedQuery<Serializable> typedQuery) {
    if (hasValue(lastName)) {
        typedQuery.setParameter("lastName", "%" + lastName.toUpperCase() + "%");
    }//from w  w  w. ja  v a2s .c o  m
    if (hasValue(account)) {
        typedQuery.setParameter("account", account);
    }
}