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.iselect.kernal.geo.dao.CountryDaoImpl.java

@Override
public List<CountryModel> getCountriesByName(String name) {
    Query query = em.createNamedQuery("country.findByName", CountryModelImpl.class);
    query.setParameter("countryName", name);
    return query.getResultList();
}

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

public Xsl findXslById(Long id) {
    Query query = entityManager.createQuery("select x from Xsl x where x.xslId = :id");
    query.setParameter("id", id);
    return (Xsl) query.getSingleResult();
}

From source file:modelo.dao.GestionUsuariosImpl.java

@Override
public List<Usuario> obtenerUsuario(String nombre, String contrasena) {
    Query q = em.createNamedQuery("Usuario.findByNombreContrasena");
    q.setParameter(1, nombre);
    q.setParameter(2, contrasena);//ww  w  . j a v  a 2s. c om
    return q.getResultList();
}

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

public Xsl findXslByCode(String code) {
    Query query = entityManager.createQuery("select x from Xsl x where x.code = :code");
    query.setParameter("code", code);
    return (Xsl) query.getSingleResult();
}

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

public void removeAllBut(SSOToken ssoToken) {
    Query query = entityManager.createQuery("DELETE FROM SessionEntity s WHERE s.ssoToken != :ssoToken");
    query.setParameter("ssoToken", ssoToken.getToken());
    query.executeUpdate();//from  w ww  . jav  a 2s  . c om
}

From source file:com.fusesource.examples.persistence.part2.dao.impl.IncidentDAOImpl.java

public List<Incident> findIncident(String key) {
    Query q = this.em.createQuery("select i from Incident as i where i.incidentRef = :ref");
    q.setParameter("ref", key);
    List list = q.getResultList();

    return list;/*from  ww w .j  av a  2s.c  o m*/
}

From source file:org.beeInvestment.repository.jpa.JpaRepositoryImpl.java

public T findById(int id) {
    Query query = this.em.createQuery(jpql + " WHERE item.id =:id");
    query.setParameter("id", id);
    return (T) query.getSingleResult();
}

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

@Override
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public UserEmailAddress findByEmailAddress(EmailAddress emailAddress) {
    Query query = entityManager.createQuery("from UserEmailAddress where emailAddress.address = :address");
    query.setParameter("address", emailAddress.getAddress());
    return getSingleResultOrNull(query);
}

From source file:com.sixsq.slipstream.persistence.Run.java

public static Run loadRunWithRuntimeParameters(String uuid) throws ConfigurationException, ValidationException {
    EntityManager em = PersistenceUtil.createEntityManager();
    Query q = createNamedQuery(em, "runWithRuntimeParameters");
    q.setParameter("uuid", uuid);
    Run run = (Run) q.getSingleResult();
    em.close();/*w w  w.  j ava 2  s . c om*/
    return run;
}

From source file:com.iselect.kernal.geo.dao.CountryDaoImpl.java

@Override
public CountryModel getCountryByCode(String code) throws EntityNotFoundException {
    CountryModel country = null;//from  www  .j  av  a2 s  .  c  o m
    Query query = em.createNamedQuery("country.findByCode", CountryModelImpl.class);
    query.setParameter("countryCode", code);
    try {
        country = (CountryModel) query.getSingleResult();
    } catch (NoResultException nre) {
        throw new EntityNotFoundException(code, nre);
    }
    return country;
}