List of usage examples for javax.persistence Query setFirstResult
Query setFirstResult(int startPosition);
From source file:com.sun.socialsite.business.impl.JPANotificationManagerImpl.java
/** * Get notifications for user's groups//from ww w. j a v a 2s. com * * Note: using SuppressWarnings annotation because the JPA API is not genericized. */ @SuppressWarnings(value = "unchecked") public List<MessageContent> getGroupNotificationsForUser(int offset, int length, Profile user) throws SocialSiteException { Query query = strategy.getNamedQuery("MessageContent.getGroupNotificationsForUser"); query.setParameter(1, user); if (offset != 0) { query.setFirstResult(offset); } if (length != -1) { query.setMaxResults(length); } return (List<MessageContent>) query.getResultList(); }
From source file:com.sun.socialsite.business.impl.JPAProfileManagerImpl.java
/** * Note: using SuppressWarnings annotation because the JPA API is not genericized. */// ww w.ja v a 2 s. c o m @SuppressWarnings(value = "unchecked") public List<Profile> getProfiles(int offset, int length) throws SocialSiteException { Query query = strategy.getNamedQuery("Profile.getAll"); if (offset != 0) query.setFirstResult(offset); if (length != -1) query.setMaxResults(length); return (List<Profile>) query.getResultList(); }
From source file:com.sun.socialsite.business.impl.JPAProfileManagerImpl.java
/** * Note: using SuppressWarnings annotation because the JPA API is not genericized. *//*from w ww. j av a 2s . c o m*/ @SuppressWarnings(value = "unchecked") public List<Profile> getOldestProfiles(int offset, int length) throws SocialSiteException { Query query = strategy.getNamedQuery("Profile.getOldest"); if (offset != 0) query.setFirstResult(offset); if (length != -1) query.setMaxResults(length); return (List<Profile>) query.getResultList(); }
From source file:eu.xipi.bro4xipi.brokermodel.BrokerJpaController.java
@SuppressWarnings("unchecked") /**/* w ww .j a va2s.com*/ * return contracts by offeredServiceName * @param firstResult * @param maxResults * @param offeredServiceName * @return */ public List<ResourceServiceContract> readContracts(int firstResult, int maxResults, String offeredServiceName) { Query q = entityManager.createQuery("SELECT c " + "FROM ResourceServiceContract c " + "JOIN c.forOfferedService s " + "WHERE s.name= :offeredServiceName"); q.setParameter("offeredServiceName", offeredServiceName); q.setFirstResult(firstResult); q.setMaxResults(maxResults); return q.getResultList(); }
From source file:co.edu.uniandes.csw.uniandes.sport.service._SportService.java
@GET public Response getSports(@Context HttpHeaders httpHeaders, @QueryParam("page") Integer page, @QueryParam("maxRecords") Integer maxRecords) { // Imprime el header que ha enviado el usuario desde el cliente try {/*from ww w . ja v a 2 s.c om*/ Subject currentUser = SecurityUtils.getSubject(); Usuario user = (Usuario) currentUser.getPrincipal(); String tenant = user.getTenant(); Map<String, Object> emProperties = new HashMap<String, Object>(); emProperties.put("eclipselink.tenant-id", tenant);//Asigna un valor al multitenant entityManager = PersistenceManager.getInstance().getEntityManagerFactory() .createEntityManager(emProperties); Query count = entityManager.createQuery("select count(u) from SportEntity u"); Long regCount = 0L; regCount = Long.parseLong(count.getSingleResult().toString()); Query q = entityManager.createQuery("select u from SportEntity u"); if (page != null && maxRecords != null) { q.setFirstResult((page - 1) * maxRecords); q.setMaxResults(maxRecords); } SportPageDTO response = new SportPageDTO(); response.setTotalRecords(regCount); response.setRecords(SportConverter.entity2PersistenceDTOList(q.getResultList())); String json = new Gson().toJson(response); return Response.status(200).header("Access-Control-Allow-Origin", "*").entity(json).build(); } catch (Exception e) { e.printStackTrace(); return Response.status(401).header("Access-Control-Allow-Origin", "*").entity("You need Authenticated") .build(); } }
From source file:com.sun.socialsite.business.impl.JPAProfileManagerImpl.java
/** * Note: using SuppressWarnings annotation because the JPA API is not genericized. *//* w w w. j a v a 2 s .c om*/ @SuppressWarnings(value = "unchecked") public List<Profile> getMostRecentlyUpdatedProfiles(int offset, int length) throws SocialSiteException { Query query = strategy.getNamedQuery("Profile.getMostRecentlyUpdated"); if (offset != 0) query.setFirstResult(offset); if (length != -1) query.setMaxResults(length); return (List<Profile>) query.getResultList(); }
From source file:org.broadleafcommerce.openadmin.server.service.persistence.module.criteria.CriteriaTranslatorImpl.java
protected void addPaging(Query response, Integer firstResult, Integer maxResults) { if (firstResult != null) { response.setFirstResult(firstResult); }/*from w ww . j a v a 2 s .co m*/ if (maxResults != null) { response.setMaxResults(maxResults); } }
From source file:com.sun.socialsite.business.impl.JPAPermissionManagerImpl.java
/** * {@inheritDoc}/* w w w. j av a 2s . c o m*/ * Note: using SuppressWarnings annotation because the JPA API is not genericized. */ @SuppressWarnings(value = "unchecked") public List<PermissionGrant> getPermissionGrants(App app, int offset, int length) throws SocialSiteException { log.debug("app=" + app); Query query = strategy.getNamedQuery("PermissionGrant.getByApp"); query.setParameter(1, app); if (offset != 0) query.setFirstResult(offset); if (length != -1) query.setMaxResults(length); return (List<PermissionGrant>) query.getResultList(); }
From source file:com.sun.socialsite.business.impl.JPANotificationManagerImpl.java
/** * Note: using SuppressWarnings annotation because the JPA API is not genericized. */// w w w . j av a 2s . com @SuppressWarnings(value = "unchecked") public List<MessageContent> getSystemNotifications(int offset, int length) throws SocialSiteException { Query query = strategy.getNamedQuery("MessageContent.getSystemNotifications"); query.setParameter(1, MessageContent.SYS_NOTIFICATIONS); if (offset != 0) { query.setFirstResult(offset); } if (length != -1) { query.setMaxResults(length); } return (List<MessageContent>) query.getResultList(); }
From source file:org.apache.roller.planet.business.jpa.JPAPlanetManagerImpl.java
public List getEntries(Subscription sub, int offset, int len) throws PlanetException { if (sub == null) { throw new PlanetException("subscription cannot be null"); }/*w w w .j a v a 2 s . c o m*/ Query q = strategy.getNamedQuery("SubscriptionEntry.getBySubscription"); q.setParameter(1, sub); if (offset != 0) q.setFirstResult(offset); if (len != -1) q.setMaxResults(len); return q.getResultList(); }