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:com.apress.prospringintegration.springenterprise.stocks.dao.jpaandentitymanagers.JpaStockDao.java

@Override
@SuppressWarnings("unchecked")
@Transactional(readOnly = true)/*  www.j av  a  2s . c o m*/
public List<Stock> findAvailableStockBySymbol(String symbol) {
    Query qu = entityManager.createQuery(" from Stock s where s.symbol = :stock ");
    qu.setParameter("stock", symbol);
    return (List<Stock>) qu.getResultList();
}

From source file:com.mothsoft.alexis.dao.RssFeedDaoImpl.java

public RssFeed findByUrl(String url) {
    final Query query = this.em.createQuery("FROM RssFeed WHERE url = :url");
    query.setParameter("url", url);

    @SuppressWarnings("unchecked")
    final List<RssFeed> results = query.getResultList();

    if (results.size() == 1) {
        return results.get(0);
    }//from  w  ww .  j  a va2 s. co  m

    return null;
}

From source file:modelo.dao.GestionProductosImpl.java

@Override
public List<Producto> obtenerProductosCategoria(int user, int categoria) {
    Query q = em.createNamedQuery("Producto.findByUserSubcategoria");
    q.setParameter(1, user);
    q.setParameter(2, categoria);/*from  www  .j av a 2  s.c om*/

    return q.getResultList();
}

From source file:com.webbfontaine.valuewebb.bpm.DocumentHistory.java

public void loadHises() {
    if (id == null) {
        return;/*from   w  ww . j  a  v a  2 s  .  c om*/
    }
    Query query = getEntityManager().createNativeQuery(getNativeQuery());
    query.setParameter("id", id);
    history = (List<Object[]>) query.getResultList();

    loadUserDetails();
}

From source file:com.mothsoft.alexis.dao.DataSetTypeDaoImpl.java

@Override
public DataSetType findSystemDataSetType(String name) {
    final Query query = this.em.createQuery("FROM DataSetType WHERE name = :name AND system = TRUE");
    query.setParameter("name", name);

    @SuppressWarnings("unchecked")
    final List<DataSetType> types = query.getResultList();

    if (types.size() > 0) {
        return types.get(0);
    }/*from w ww . j  a  v  a 2  s  . c  om*/

    return null;
}

From source file:org.simbasecurity.core.domain.repository.SSOTokenMappingDatabaseRepository.java

public void remove(String token) {
    Query query = entityManager.createQuery("DELETE FROM SSOTokenMappingEntity tm WHERE tm.token = :token");
    query.setParameter("token", token);
    query.executeUpdate();//from  w ww.  j  a v  a2  s  . c om
}

From source file:com.tapas.evidence.repository.KindergartenRepositoryImpl.java

@Override
@SuppressWarnings("unchecked")
public List<Kindergarten> findAll() {
    final Long tenantId = ((EvidenceUserDetails) SecurityContextHolder.getContext().getAuthentication()
            .getPrincipal()).getTenantId();
    Query query = this.entityManager.createNamedQuery(Kindergarten.QUERY_NAME_FIND_ALL_BY_DELETED_FLAG);
    query.setParameter("deleted", Boolean.FALSE);
    query.setParameter("tenantId", tenantId);
    return query.getResultList();
}

From source file:org.kuali.mobility.xsl.dao.XslDaoImpl.java

public void deleteXslById(Long id) {
    Query query = entityManager.createQuery("delete from Xsl x where x.xslId = :id");
    query.setParameter("id", id);
    query.executeUpdate();// w  w  w .j a va 2 s  .c o m
}

From source file:org.simbasecurity.core.domain.repository.LoginMappingDatabaseRepository.java

@Override
public void remove(String token) {
    Query query = entityManager.createQuery("DELETE FROM LoginMappingEntity lm WHERE lm.token = :token");
    query.setParameter("token", token);
    query.executeUpdate();/*w  w w .j  av  a2s .  co  m*/
}

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

public Role findByName(String name) {
    Query query = getEntityManager().createQuery("SELECT r FROM Role r WHERE r.name = :name");

    query.setParameter("name", name);

    return (Role) query.getSingleResult();
}