List of usage examples for javax.persistence Query setParameter
Query setParameter(int position, Object value);
From source file:ispok.dao.CashgameSessionHibernateJpaDao.java
@Override public List<CashgameSession> getActiveByCashgameId(Long cashgameId) { String jpql = "SELECT cs FROM CashgameSession cs WHERE cs.cashgame.id = :id AND cs.stop IS NULL"; Query query = getEntityManager().createQuery(jpql); query.setParameter("id", cashgameId); @SuppressWarnings("unchecked") List<CashgameSession> cashgameSessions = query.getResultList(); return cashgameSessions; }
From source file:com.excilys.ebi.sample.jpa.query.benchmark.repository.impl.NamedQueryRepository.java
@Override @SuppressWarnings("unchecked") public List<Song> getSongsByArtistNameOrderBySongTitle(String name) { Query query = em.createNamedQuery("getSongsByArtistName"); query.setParameter(1, name); return query.getResultList(); }
From source file:com.excilys.ebi.sample.jpa.query.benchmark.repository.impl.NamedQueryRepository.java
@Override @SuppressWarnings("unchecked") public List<Song> getSongsBySameArtistOrderBySongTitle(Integer songId) { Query query = em.createNamedQuery("getSongsBySameArtist"); query.setParameter(1, songId); return query.getResultList(); }
From source file:com.gymadmin.persistence.dao.impl.PaymentMethodDaoImpl.java
@SuppressWarnings("unchecked") public List<PaymentPlanEntity> findByFilters(Map<String, String> filters) { Query namedQuery = em.createNamedQuery("PaymentMethodEntity.findByFilters"); namedQuery.setParameter("name", "%" + filters.get("name").toUpperCase() + "%"); namedQuery.setParameter("description", "%" + filters.get("description").toUpperCase() + "%"); return (List<PaymentPlanEntity>) namedQuery.getResultList(); }
From source file:com.mycompany.testeproject.ColaboradorDAO.java
public Tcolaborador getColaboradorByNrColaborador(long nrColaborador) { Query q = em.createNamedQuery("Tcolaborador.findByNrColaborador"); q.setParameter("nrColaborador", nrColaborador); return (Tcolaborador) q.getSingleResult(); }
From source file:co.sip.dmesmobile.bs.ScUsersDao.java
public ScUsers findByLogin(String login) throws Exception { entityManager = Factory.getEntityManagerFactory().createEntityManager(); ScUsers result = null;/*from ww w .j a v a2 s. c o m*/ try { Query query = entityManager.createNamedQuery("ScUsers.findByLogin"); query.setParameter("login", login); result = (ScUsers) query.getSingleResult(); } catch (Exception e) { log.error("Error intentando consultar el usuario", e.getCause()); } return result; }
From source file:com.healthcit.cacure.dao.QuestionTableDao.java
/** * @return Next Ord Number in ordered entities. *///from w ww. jav a 2 s . co m @Transactional(propagation = Propagation.SUPPORTS) public Integer calculateNextOrdNumber(Long formId) { String jpql = "select MAX(ord + 1) from TableQuestion q, FormElement e where q.parent_id=e.id and e.form.id = :formId"; Query query = em.createQuery(jpql); query.setParameter("formId", formId); return (Integer) query.getSingleResult(); }
From source file:com.linksinnovation.elearning.repository.CourseDTORepository.java
public List<CourseDTO> findByCategory(Map<String, Long> map) { List<Object[]> result; if (null != map.get("category")) { String queryString = query + " WHERE category_id=:cat"; if (null != map.get("subcategory")) { queryString = queryString + " AND sub_category_id=:subcat"; }//w w w . ja v a 2s .c o m Query q = em.createNativeQuery(queryString); q.setParameter("cat", map.get("category")); if (null != map.get("subcategory")) { q.setParameter("subcat", map.get("subcategory")); } result = q.getResultList(); } else { result = Collections.EMPTY_LIST; } return mapObject(result); }
From source file:com.mycompany.testeproject.AusenciaDAO.java
public Tausencia getAusenciaByIdAusencia(Integer idAusencia) { Query q = em.createNamedQuery("Tausencia.findByIdAusencia"); q.setParameter("idAusencia", idAusencia); Ausencia ausencia = null;//from ww w . j a va 2 s . c om Tausencia savedAusencia = null; if (ausencia.getIdAusencia() != null) { savedAusencia = em.find(Tausencia.class, ausencia.getIdAusencia()); return (Tausencia) q.getSingleResult(); } else { return null; } }
From source file:com.gymadmin.persistence.dao.impl.PaymentDaoImpl.java
@Override public List<PaymentEntity> findByFilters(Map<String, Object> filters) { Query namedQuery = em.createNamedQuery("PaymentEntity.findAllByFilters"); namedQuery.setParameter("stateId", filters.get("stateId") == null ? 0 : (Integer) filters.get("stateId")); namedQuery.setParameter("customerName", "%" + (filters.get("customerName") == null ? "" : (String) filters.get("customerName")) + "%"); return (List<PaymentEntity>) namedQuery.getResultList(); }