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:de.taimos.dao.hibernate.EntityDAOHibernate.java

private <T> List<T> findListByQueryLimit(final String query, Class<T> clazz, final int first, final int max,
        final Object... params) {
    final TypedQuery<T> tq = this.entityManager.createQuery(query, clazz);
    for (int i = 0; i < params.length; i++) {
        tq.setParameter(i + 1, params[i]);
    }//  w w  w. j  a  va 2  s  .  c o m
    if (first >= 0) {
        tq.setFirstResult(first);
    }
    if (max >= 0) {
        tq.setMaxResults(max);
    }
    return tq.getResultList();
}

From source file:de.lava.marvin.whaosleaguepersistence.dao.impl.PlayerDaoImpl.java

@Override
public List<Match> getAllMatchesForPlayer(Player p) {
    TypedQuery<Match> query = entityManager.createNamedQuery("allMatchesForPlayer", Match.class);
    query.setParameter("player", p);
    return query.getResultList();
}

From source file:de.lava.marvin.whaosleaguepersistence.dao.impl.PlayerDaoImpl.java

@Override
public long getCountAllWinsForPlayer(Player p) {
    TypedQuery<Long> query = entityManager.createNamedQuery("countAllWinsForPlayer", Long.class);
    query.setParameter("player", p);
    return query.getSingleResult();
}

From source file:de.lava.marvin.whaosleaguepersistence.dao.impl.PlayerDaoImpl.java

@Override
public long getCountAllLosesForPlayer(Player p) {
    TypedQuery<Long> query = entityManager.createNamedQuery("countAllLosesForPlayer", Long.class);
    query.setParameter("player", p);
    return query.getSingleResult();
}

From source file:de.lava.marvin.whaosleaguepersistence.dao.impl.PlayerDaoImpl.java

@Override
public List<Match> getAllRankedWinsForPlayer(Player p) {
    TypedQuery<Match> query = entityManager.createNamedQuery("allRankedWinsForPlayer", Match.class);
    query.setParameter("player", p);
    return query.getResultList();
}

From source file:de.lava.marvin.whaosleaguepersistence.dao.impl.PlayerDaoImpl.java

@Override
public long getCountAllMatchesForPlayer(Player p) {
    TypedQuery<Long> query = entityManager.createNamedQuery("countAllMatchesForPlayer", Long.class);
    query.setParameter("player", p);
    return query.getSingleResult();
}

From source file:de.lava.marvin.whaosleaguepersistence.dao.impl.PlayerDaoImpl.java

@Override
public List<Match> getAllRankedLosesForPlayer(Player p) {
    TypedQuery<Match> query = entityManager.createNamedQuery("allRankedLosesForPlayer", Match.class);
    query.setParameter("player", p);
    return query.getResultList();
}

From source file:de.lava.marvin.whaosleaguepersistence.dao.impl.PlayerDaoImpl.java

@Override
public List<Match> getAllUnrankedWinsForPlayer(Player p) {
    TypedQuery<Match> query = entityManager.createNamedQuery("allUnrankedWinsForPlayer", Match.class);
    query.setParameter("player", p);
    return query.getResultList();
}

From source file:de.lava.marvin.whaosleaguepersistence.dao.impl.PlayerDaoImpl.java

@Override
public List<Match> getAllRankedMatchesForPlayer(Player p) {
    TypedQuery<Match> query = entityManager.createNamedQuery("allRankedMatchesForPlayer", Match.class);
    query.setParameter("player", p);
    return query.getResultList();
}

From source file:de.lava.marvin.whaosleaguepersistence.dao.impl.PlayerDaoImpl.java

@Override
public List<Match> getAllUnrankedLosesForPlayer(Player p) {
    TypedQuery<Match> query = entityManager.createNamedQuery("allUnrankedLosesForPlayer", Match.class);
    query.setParameter("player", p);
    return query.getResultList();
}