List of usage examples for javax.persistence TypedQuery getResultList
List<X> getResultList();
From source file:org.openmeetings.app.data.basic.Configurationmanagement.java
/** * //w ww .j a v a 2 s .co m * @return */ private Long selectMaxFromConfigurations() { try { log.debug("selectMaxFromConfigurations "); // get all users TypedQuery<Long> query = em.createQuery( "select count(c.configuration_id) from Configuration c where c.deleted = 'false'", Long.class); List<Long> ll = query.getResultList(); log.debug("selectMaxFromConfigurations" + ll.get(0)); return ll.get(0); } catch (Exception ex2) { log.error("[selectMaxFromConfigurations] ", ex2); } return null; }
From source file:com.abiquo.server.core.cloud.VirtualMachineDAO.java
public List<VirtualMachine> findVirtualMachinesByDatacenter(final Integer datacenterId) { List<VirtualMachine> vmList = null; TypedQuery<VirtualMachine> query = getEntityManager().createNamedQuery("VIRTUAL_MACHINE.BY_DC", VirtualMachine.class); query.setParameter("datacenterId", datacenterId); vmList = query.getResultList(); return vmList; }
From source file:org.mmonti.entitygraph.repository.CustomGenericJpaRepository.java
@Override public List<T> findAll(Specification<T> spec, EntityGraphType type, String... attributeGraph) { final TypedQuery<T> typedQuery = getQuery(spec, (Sort) null); if (attributeGraph != null && attributeGraph.length > 0) { final EntityGraph<T> entityGraph = this.entityManager.createEntityGraph(getDomainClass()); buildEntityGraph(entityGraph, attributeGraph); typedQuery.setHint(type.getType(), entityGraph); }/* ww w . ja va 2s . c o m*/ return typedQuery.getResultList(); }
From source file:org.synyx.hades.dao.orm.GenericJpaDao.java
public List<T> readAll(final Sort sort) { String queryString = QueryUtils.applySorting(getReadAllQueryString(), sort); TypedQuery<T> query = getEntityManager().createQuery(queryString, getDomainClass()); return (null == sort) ? readAll() : query.getResultList(); }
From source file:com.epam.training.taranovski.web.project.repository.implementation.OfferBidRepositoryImplementation.java
@Override public List<Employee> getOffersForVacancy(Vacancy vacancy) { EntityManager em = entityManagerFactory.createEntityManager(); List<Employee> list = new LinkedList<>(); try {//from ww w. java2 s. co m em.getTransaction().begin(); TypedQuery<Employee> query = em.createNamedQuery("OfferBid.findEmployeeOffersForVacancy", Employee.class); query.setParameter("vacancy", vacancy); list = query.getResultList(); em.getTransaction().commit(); } catch (RuntimeException e) { Logger.getLogger(OfferBidRepositoryImplementation.class.getName()).info(e); } finally { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } em.close(); } return list; }
From source file:org.openmeetings.app.data.calendar.daos.MeetingMemberDaoImpl.java
public List<MeetingMember> getMeetingMemberByAppointmentId(Long appointmentId) { try {//from ww w .j a v a 2 s. c o m log.debug("getMeetingMemberByAppointmentId: " + appointmentId); String hql = "select app from MeetingMember app " + "WHERE app.deleted <> :deleted " + "AND app.appointment.appointmentId = :appointmentId"; TypedQuery<MeetingMember> query = em.createQuery(hql, MeetingMember.class); query.setParameter("deleted", true); query.setParameter("appointmentId", appointmentId); List<MeetingMember> listmeetingMember = query.getResultList(); return listmeetingMember; } catch (Exception ex2) { log.error("[getMeetingMemberByAppointmentId]: ", ex2); } return null; }
From source file:org.openmeetings.app.data.file.dao.FileExplorerItemDaoImpl.java
public List<FileExplorerItem> getFileExplorerItems() { log.debug(".getFileExplorerItemsById() started"); try {//from www . j a va2s . c o m String hql = "SELECT c FROM FileExplorerItem c "; TypedQuery<FileExplorerItem> query = em.createQuery(hql, FileExplorerItem.class); List<FileExplorerItem> fileExplorerList = query.getResultList(); return fileExplorerList; } catch (Exception ex2) { log.error("[getFileExplorerItemsById]: ", ex2); } return null; }
From source file:org.cleverbus.core.common.dao.ExternalCallDaoJpaImpl.java
@Override @Nullable//from www. j a v a 2 s .co m @SuppressWarnings("unchecked") public ExternalCall findConfirmation(int interval) { // find confirmation that was lastly processed before specified interval Date lastUpdateLimit = DateUtils.addSeconds(new Date(), -interval); String jSql = "SELECT c " + "FROM " + ExternalCall.class.getName() + " c " + "WHERE c.operationName = :operationName" + " AND c.state = :state" + " AND c.lastUpdateTimestamp < :lastUpdateTimestamp" + " ORDER BY c.creationTimestamp"; TypedQuery<ExternalCall> q = em.createQuery(jSql, ExternalCall.class); q.setParameter("operationName", ExternalCall.CONFIRM_OPERATION); q.setParameter("state", ExternalCallStateEnum.FAILED); q.setParameter("lastUpdateTimestamp", new Timestamp(lastUpdateLimit.getTime())); q.setMaxResults(1); List<ExternalCall> extCalls = q.getResultList(); if (extCalls.isEmpty()) { return null; } else { return extCalls.get(0); } }
From source file:com.music.dao.PieceDao.java
public List<Piece> getFeedEntryPiecesInRange(DateTime start, DateTime end) { TypedQuery<Piece> query = getEntityManager().createQuery( "SELECT e.piece FROM FeedEntry e WHERE e.inclusionTime > :start AND e.inclusionTime < :end ORDER BY e.piece.generationTime DESC", Piece.class); query.setParameter("start", start); query.setParameter("end", end); return query.getResultList(); }
From source file:org.openmeetings.app.data.conference.dao.RoomModeratorsDaoImpl.java
public List<RoomModerators> getRoomModeratorByRoomId(Long roomId) { try {/*from w w w . j a va 2 s .c om*/ String hql = "select c from RoomModerators as c " + "where c.roomId = :roomId AND c.deleted <> :deleted"; TypedQuery<RoomModerators> query = em.createQuery(hql, RoomModerators.class); query.setParameter("deleted", "true"); query.setParameter("roomId", roomId); List<RoomModerators> roomModerators = query.getResultList(); return roomModerators; } catch (Exception ex2) { log.error("[getRoomModeratorByRoomId] ", ex2); ex2.printStackTrace(); } return null; }