List of usage examples for javax.persistence Query getResultList
List getResultList();
From source file:com.healthcit.cacure.dao.ModuleDao.java
@SuppressWarnings("unchecked") public List<BaseModule> getLibraryModules() { //By default it returns order by last update date. Query query = em.createQuery("select m from BaseModule m where m.isLibrary = true order by id"); return query.getResultList(); }
From source file:com.linksinnovation.elearning.repository.ViewAmountRepository.java
public List<ViewAmount> findByCondition(BasicConditionDTO amountDTO) { if (null == amountDTO.getCategory() && null == amountDTO.getStart()) { String queryAppend = queryString + " ORDER BY update_date,user ASC"; Query query = em.createNativeQuery(queryAppend); List<Object[]> resultList = query.getResultList(); return mapObject(resultList); } else if (null != amountDTO.getCategory() && null == amountDTO.getStart()) { String queryAppend = queryString + " WHERE category_id=:cat"; if (null != amountDTO.getSubCategory()) { queryAppend = queryAppend + " AND sub_category_id=:subcat"; }//from w w w . j a v a2 s. com queryAppend = queryAppend + " ORDER BY update_date,user ASC"; Query query = em.createNativeQuery(queryAppend); query.setParameter("cat", amountDTO.getCategory()); if (null != amountDTO.getSubCategory()) { query.setParameter("subcat", amountDTO.getSubCategory()); } List<Object[]> resultList = query.getResultList(); return mapObject(resultList); } else if (null != amountDTO.getCategory() && null != amountDTO.getStart() && null != amountDTO.getEnd()) { String queryAppend = queryString + " WHERE update_date BETWEEN :start AND :end AND category_id=:cat"; if (null != amountDTO.getSubCategory()) { queryAppend = queryAppend + " AND sub_category_id=:subcat"; } queryAppend = queryAppend + " ORDER BY update_date,user ASC"; Query query = em.createNativeQuery(queryAppend); query.setParameter("start", amountDTO.getStart()); query.setParameter("end", amountDTO.getEnd()); query.setParameter("cat", amountDTO.getCategory()); if (null != amountDTO.getSubCategory()) { query.setParameter("subcat", amountDTO.getSubCategory()); } List<Object[]> resultList = query.getResultList(); return mapObject(resultList); } else if (null == amountDTO.getCategory() && null != amountDTO.getStart() && null != amountDTO.getEnd()) { String queryAppend = queryString + " WHERE update_date BETWEEN :start AND :end"; queryAppend = queryAppend + " ORDER BY update_date,user ASC"; Query query = em.createNativeQuery(queryAppend); query.setParameter("start", amountDTO.getStart()); query.setParameter("end", amountDTO.getEnd()); List<Object[]> resultList = query.getResultList(); return mapObject(resultList); } else { String queryAppend = queryString + " ORDER BY update_date,user ASC"; Query query = em.createNativeQuery(queryAppend); List<Object[]> resultList = query.getResultList(); return mapObject(resultList); } }
From source file:com.luna.common.repository.UserRepository2Impl.java
public List<SchoolInfo> findAllSchoolTypeByUserId(Long userId) { String ql = "select si from SchoolInfo si where si.user.id=?1"; Query query = entityManager.createQuery(ql); query.setParameter(1, userId);// www . j a v a2s . c om return query.getResultList(); }
From source file:com.expressui.core.dao.security.UserDao.java
/** * Finds all Users ordered by login name. * * @return all roles//from w w w . j a va 2s . c om */ @Override public List<User> findAll() { Query query = getEntityManager().createQuery("SELECT u FROM User u ORDER BY u.loginName"); setReadOnly(query); return query.getResultList(); }
From source file:cz.fi.muni.pa036.airticketbooking.dao.impl.PlaneDaoImpl.java
@Override public List<Plane> getAll() { try {/*from ww w . jav a 2s. co m*/ Query q = em.createQuery("FROM Plane"); List<Plane> planes = q.getResultList(); return Collections.unmodifiableList(planes); } catch (PersistenceException | IllegalArgumentException ex) { throw new DataAccessException(ex.getMessage(), ex) { }; } }
From source file:de.inetsource.jsfforum.db.ThreadFacade.java
public List<Thread> findArticlesFromTopic(Integer forumId) { Query query = getEntityManager().createNamedQuery("Thread.findByForumId"); query.setParameter("id", new Forum(forumId)); return query.getResultList(); }
From source file:info.toegepaste.www.service.PdfServiceImpl.java
@Override @TransactionAttribute(REQUIRES_NEW)//from w w w. j a v a 2s. com public List<Score> getAllScores() { Query q = em.createNamedQuery("Score.findAll"); return (List<Score>) q.getResultList(); }
From source file:org.simbasecurity.core.domain.repository.PolicyDatabaseRepository.java
@SuppressWarnings("unchecked") @Override/*from w w w . ja v a 2 s . c o m*/ public Collection<Policy> findNotLinked(Role role) { ArrayList<Policy> result = new ArrayList<Policy>(); Query query = entityManager.createQuery("SELECT p FROM PolicyEntity p "); List<Policy> temp = (List<Policy>) query.getResultList(); for (Policy policy : temp) { if (!policy.getRoles().contains(role)) { result.add(policy); } } return result; // TODO: use implementation below when hibernate bug (HHH-8907) is fixed // Query query = entityManager.createQuery( // "SELECT p FROM PolicyEntity p " + // "WHERE :role not in " + // "(p.roles) order by p.name") // .setParameter("role", role); // return query.getResultList(); }
From source file:org.thingsplode.TestBaseWithRepos.java
protected Integer getCountWhere(String tableName, String whereCriteria) { Query q = entityManager.createNativeQuery("select count(*) from " + tableName + " where " + whereCriteria); return ((BigInteger) q.getResultList().get(0)).intValue(); }
From source file:com.expressui.sample.dao.CurrencyDao.java
private List<Currency> findAllWithoutFxRates() { Query query = getEntityManager().createQuery("SELECT c FROM Currency c ORDER BY c.name"); setReadOnly(query);/*from w w w .j av a 2s. c om*/ return query.getResultList(); }