List of usage examples for javax.persistence Query getResultList
List getResultList();
From source file:com.tapas.evidence.repository.ChildRepositoryImpl.java
@Override @SuppressWarnings("unchecked") public List<Child> findAll() { final Long tenantId = ((EvidenceUserDetails) SecurityContextHolder.getContext().getAuthentication() .getPrincipal()).getTenantId(); Query query = this.entityManager.createNamedQuery(Child.QUERY_NAME_FIND_ALL_BY_DELETED_FLAG); query.setParameter("deleted", Boolean.FALSE); query.setParameter("tenantId", tenantId); return query.getResultList(); }
From source file:com.tapas.evidence.repository.TeacherRepositoryImpl.java
@Override @SuppressWarnings("unchecked") public List<Teacher> findAll() { final Long tenantId = ((EvidenceUserDetails) SecurityContextHolder.getContext().getAuthentication() .getPrincipal()).getTenantId(); Query query = this.entityManager.createNamedQuery(Teacher.QUERY_NAME_FIND_ALL_BY_DELETED_FLAG); query.setParameter("deleted", Boolean.FALSE); query.setParameter("tenantId", tenantId); return query.getResultList(); }
From source file:de.alpharogroup.message.system.service.MessageRecipientsBusinessService.java
@Override @SuppressWarnings("unchecked") public boolean deleteMessageRecipient(final Users recipient, final Messages message) { final String hqlSelectString = "select distinct mr from " + MessageRecipients.class.getSimpleName() + " mr " + "where mr.recipient=:recipient " + "and mr.message=:message"; final Query query = getQuery(hqlSelectString); query.setParameter("recipient", recipient); query.setParameter("message", message); final List<MessageRecipients> toDel = query.getResultList(); if (toDel != null && !toDel.isEmpty()) { for (final Iterator<MessageRecipients> iterator = toDel.iterator(); iterator.hasNext();) { MessageRecipients messageRecipient = iterator.next(); messageRecipient.setMessage(null); messageRecipient.setRecipient(null); messageRecipient = merge(messageRecipient); delete(messageRecipient);//from ww w . j a v a 2s.c o m } return true; } return false; }
From source file:org.simbasecurity.core.domain.repository.RuleDatabaseRepository.java
@SuppressWarnings("unchecked") Collection<ResourceRule> getResourceRulesDirectly(String username, String resource) { Query query = entityManager.createQuery(QUERY_RESOURCE_RULES_FOR_USER); query.setParameter(USERNAME, username).setParameter(RESOURCE, resource.toLowerCase()); return query.getResultList(); }
From source file:com.dhenton9000.birt.persistence.dao.impl.EmployeesDaoImpl.java
@Override public List<SalesReport> getSalesData() { String qString = "select new com.dhenton9000.birt." + "persistence.entities.SalesReport(e.firstName, e.lastName," + "SUM(details.priceEach),e.employeeNumber)" + " from Orders o" + " join o.orderDetails details" + " join o.customer cust " + " join cust.employee e " + " GROUP BY e.employeeNumber" + " ORDER BY e.lastName, e.firstName"; Query q = this.getEntityManager().createQuery(qString); //q.setParameter("id", employeeId); List<SalesReport> salesData = q.getResultList(); // http://www.objectdb.com/java/jpa/query/jpql/select return salesData; }
From source file:org.syncope.core.persistence.dao.impl.ResourceDAOImpl.java
@Override public List<SchemaMapping> findAllMappings() { Query query = entityManager.createQuery("SELECT e FROM " + SchemaMapping.class.getSimpleName() + " e"); return query.getResultList(); }
From source file:ch.javaee.basicMvc.repository.UserRepositoryImpl.java
@Override @Transactional(readOnly = false)/*from w w w . j a v a 2 s .c o m*/ public List<String> findUsername(String username) { Query query = em.createQuery("select u.username from user u where username like :username") .setParameter("username", username + "%").setMaxResults(5); return query.getResultList(); }
From source file:com.ovalsearch.dao.impl.ApplicationsDaoImpl.java
@SuppressWarnings("unchecked") @Override//from ww w . j ava2 s . co m @Transactional public List<Applications> getAllApplications() { Query query = entityDao.getEntityManager().createQuery( "Select applications from Applications applications order by downloads DESC, rating DESC"); List<Applications> resultSet = (List<Applications>) query.getResultList(); return resultSet; }
From source file:ispok.dao.LevelHibernateJpaDao.java
@Override @SuppressWarnings("unchecked") public Level get(int duration, int breakDuration, Long betsetId) { String jpql = "SELECT l FROM Level l WHERE l.duration = :duration AND l.breakDuration = :breakDuration AND l.betset.id = :betsetId"; Query query = getEntityManager().createQuery(jpql); query.setParameter("duration", duration); query.setParameter("breakDuration", breakDuration); query.setParameter("betsetId", betsetId); List<Level> l = query.getResultList(); if (l.isEmpty()) { return null; }/*from w w w .j av a2 s . c o m*/ return l.get(0); }
From source file:com.exp.tracker.services.impl.JpaPaymentService.java
@SuppressWarnings("unchecked") @Transactional(readOnly = true)/* w w w .j a va 2s .co m*/ public List<PaymentBean> getAllPayments() { List<PaymentBean> paymentList = new ArrayList<PaymentBean>(); Query queryGetAllPayments = null; queryGetAllPayments = em.createNamedQuery("allPayments"); // get a list of results Collection<Object[]> results = queryGetAllPayments.getResultList(); for (Object[] oa : results) { PaymentBean pb = new PaymentBean(); // Each object is a list pb.setAmount(((Float) oa[0]).floatValue()); pb.setSettledFlag(((Integer) oa[1]).intValue()); pb.setStartDate(((Date) oa[2])); pb.setEndDate(((Date) oa[3])); pb.setSettlementId(((Long) oa[4]).longValue()); pb.setUserName(((String) oa[5])); pb.setUserSettlementId(((Long) oa[6]).longValue()); paymentList.add(pb); } return paymentList; }