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:cz.fi.muni.pa036.airticketbooking.dao.impl.UserRoleDaoImpl.java

@Override
public UserRole findByUser(User user) {
    final Query query = em.createQuery("from UserRole where user = :user");
    query.setParameter("user", user);
    return (UserRole) query.getSingleResult();
}

From source file:com.healthcit.cacure.dao.UserManagerDao.java

@Transactional(readOnly = true)
public UserCredentials findByName(String uName) {
    Query query = this.em.createQuery("from UserCredentials where username = :uName");
    query.setParameter("uName", uName);
    return (UserCredentials) query.getSingleResult();
}

From source file:de.inetsource.jsfforum.db.PostFacade.java

public List<Post> findPostsFromTopic(Integer threadId) {
    Query query = getEntityManager().createNamedQuery("Post.findByThreadId");
    query.setParameter("id", threadId);
    return query.getResultList();
}

From source file:com.dhenton9000.birt.jpa.service.impl.security.UsersServiceImpl.java

@Override
public List<Applications> findAuthorizedApplications(Integer id) {

    String qString = "select applications " + " from Users users " + " join users.groupsSet groups "
            + " join groups.applicationsSet applications " + " where users.userid = :id ";

    Query q = this.entityManager.createQuery(qString);
    q.setParameter("id", id);
    return q.getResultList();
}

From source file:com.dhenton9000.birt.jpa.service.impl.security.UsersServiceImpl.java

@Override
public List<Groups> findGroupsForUser(Integer id) {

    String qString = "select groups " + " from Users users " + " join users.groupsSet groups "
            + " where users.userid = :id ";

    Query q = this.entityManager.createQuery(qString);
    q.setParameter("id", id);
    return q.getResultList();
}

From source file:com.tamnd.app.core.repositories.jpa.AccountRoleRepoImpl.java

@Override
public AccountRole findAccountRoleByName(String roleName) {
    Query query = em.createQuery("SELECT a FROM AccountRole a WHERE a.roleName=?1");
    query.setParameter(1, roleName);
    List<AccountRole> list = query.getResultList();
    if (list.isEmpty()) {
        return null;
    } else {/*from  w w w . j ava  2 s. co m*/
        return list.get(0);
    }
}

From source file:modelo.dao.GestionHistoricoImpl.java

@Override
public List<Historico> obtenerHistorico(String referencia, int usuario) {
    Query q = em.createNamedQuery("Historico.findLastDateByRef");
    q.setParameter(1, referencia);
    q.setParameter(2, usuario);//from   w w w . j a  v  a  2s.  co  m
    return q.getResultList();
}

From source file:com.tamnd2.basicwebapp.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=?1");
    query.setParameter(1, accountId);
    return query.getResultList();
}

From source file:de.inetsource.jsfforum.db.PostFacade.java

public List<Post> findRange(Thread thread, int[] rangeArray) {
    Query query = getEntityManager().createNamedQuery("Post.findByThreadId");
    query.setParameter("id", thread.getId());
    query.setFirstResult(rangeArray[0]);
    query.setMaxResults(rangeArray[1]);/*from w ww.ja v  a2s . c  om*/
    return query.getResultList();
}

From source file:nc.noumea.mairie.appock.dao.impl.AppUserDaoImpl.java

@SuppressWarnings("unchecked")
@Override/*from www  . j a  v  a  2  s.  c  o m*/
public List<AppUser> findAllWithRole(Role role) {
    String orderBy = " ORDER BY u.actif desc, u.nom, u.prenom asc";
    String requeteJpa = "SELECT u FROM AppUser u INNER JOIN u.listeRole r " //
            + " WHERE r=:role " //
            + orderBy;
    Query query = persistentManager.getEntityManager().createQuery(requeteJpa);
    query.setParameter("role", role);
    return query.getResultList();
}