List of usage examples for javax.persistence TypedQuery getResultList
List<X> getResultList();
From source file:eu.domibus.common.dao.MessageLogDao.java
public List<MessageLogEntry> findAll() { final TypedQuery<MessageLogEntry> query = this.em.createNamedQuery("MessageLogEntry.findEntries", MessageLogEntry.class); return query.getResultList(); }
From source file:net.groupbuy.dao.impl.MemberDaoImpl.java
public List<Object[]> findPurchaseList(Date beginDate, Date endDate, Integer count) { CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); CriteriaQuery<Object[]> criteriaQuery = criteriaBuilder.createQuery(Object[].class); Root<Member> member = criteriaQuery.from(Member.class); Join<Product, Order> orders = member.join("orders"); criteriaQuery.multiselect(member.get("id"), member.get("username"), member.get("email"), member.get("point"), member.get("amount"), member.get("balance"), criteriaBuilder.sum(orders.<BigDecimal>get("amountPaid"))); Predicate restrictions = criteriaBuilder.conjunction(); if (beginDate != null) { restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.greaterThanOrEqualTo(orders.<Date>get("createDate"), beginDate)); }// w w w .jav a 2s .c om if (endDate != null) { restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.lessThanOrEqualTo(orders.<Date>get("createDate"), endDate)); } restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.equal(orders.get("orderStatus"), OrderStatus.completed), criteriaBuilder.equal(orders.get("paymentStatus"), PaymentStatus.paid)); criteriaQuery.where(restrictions); criteriaQuery.groupBy(member.get("id"), member.get("username"), member.get("email"), member.get("point"), member.get("amount"), member.get("balance")); criteriaQuery.orderBy(criteriaBuilder.desc(criteriaBuilder.sum(orders.<BigDecimal>get("amountPaid")))); TypedQuery<Object[]> query = entityManager.createQuery(criteriaQuery).setFlushMode(FlushModeType.COMMIT); if (count != null && count >= 0) { query.setMaxResults(count); } return query.getResultList(); }
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:fr.univrouen.poste.web.ForgotPasswordController.java
@RequestMapping(value = "/forgotpassword/update", method = RequestMethod.POST) public String update(@ModelAttribute("forgotpasswordForm") @Valid ForgotPasswordForm form, BindingResult result, HttpServletRequest request) {/*from w w w.j a v a2 s .c o m*/ if (result.hasErrors()) { return "forgotpassword/index"; } else { TypedQuery<User> userQuery = User .findUsersByEmailAddressAndActivationDateIsNotNull(form.getEmailAddress(), null, null); if (null != userQuery && !userQuery.getResultList().isEmpty()) { User user = userQuery.getSingleResult(); String activationKey = generateActivationKey(); user.setActivationKey(activationKey); user.merge(); String mailTo = form.getEmailAddress(); String mailFrom = AppliConfig.getCacheMailFrom(); String mailSubject = AppliConfig.getCacheMailSubject(); String mailMessage = AppliConfig.getCacheTexteMailPasswordOublie(); mailMessage = mailMessage.replaceAll("@@activationKey@@", activationKey); logService.logActionAuth(LogService.AUTH_PASSWORD_FORGOT_SENT, user.getEmailAddress(), request.getRemoteAddr()); emailService.sendMessage(mailFrom, mailTo, mailSubject, mailMessage); } else { logService.logActionAuth(LogService.AUTH_PASSWORD_FORGOT_FAILED, form.getEmailAddress(), request.getRemoteAddr()); } return "forgotpassword/thanks"; } }
From source file:org.mitre.openid.connect.repository.impl.JpaWhitelistedSiteRepository.java
@Override @Transactional(value = "defaultTransactionManager") public WhitelistedSite getByClientId(String clientId) { TypedQuery<WhitelistedSite> query = manager.createNamedQuery(WhitelistedSite.QUERY_BY_CLIENT_ID, WhitelistedSite.class); query.setParameter(WhitelistedSite.PARAM_CLIENT_ID, clientId); return JpaUtil.getSingleResult(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(); }
From source file:de.lava.marvin.whaosleaguepersistence.dao.impl.PlayerDaoImpl.java
@Override public List<Match> getAllUnrankedMatchesForPlayer(Player p) { TypedQuery<Match> query = entityManager.createNamedQuery("allUnrankedMatchesForPlayer", Match.class); query.setParameter("player", p); return query.getResultList(); }
From source file:net.nan21.dnet.core.business.service.entity.AbstractEntityReadService.java
/** * Find a list of entities of the given type, using as filter criteria the * specified list of attribute values.//from w w w .j av a 2s .c o m * * @param entityClass * @param params * @return * @throws BusinessException */ public <T> List<T> findEntitiesByAttributes(Class<T> entityClass, Map<String, Object> params) { CriteriaBuilder cb = this.getEntityManager().getCriteriaBuilder(); CriteriaQuery<T> cq = cb.createQuery(entityClass); Root<T> root = cq.from(entityClass); cq.select(root); Assert.notNull(params); Predicate p = null; if (entityClass.isAssignableFrom(IModelWithClientId.class)) { p = cb.equal(root.get("clientId"), Session.user.get().getClient().getId()); } for (Map.Entry<String, Object> entry : params.entrySet()) { p = cb.and(cb.equal(root.get(entry.getKey()), entry.getValue())); } cq.where(p); TypedQuery<T> query = this.getEntityManager().createQuery(cq); return (List<T>) query.getResultList(); }