List of usage examples for javax.persistence TypedQuery setMaxResults
TypedQuery<X> setMaxResults(int maxResult);
From source file:ar.edu.unlp.sedici.sedici2003.model.JerarquiasTermino.java
public static List<JerarquiasTermino> findAll(String text, String[] parents, boolean includeChilds, boolean includeSelf, int start, int count) { if (text == null || text.length() == 0) throw new IllegalArgumentException("The text argument is required"); if (parents == null || parents.length == 0) throw new IllegalArgumentException("The parents argument is required"); if (start < 0) start = 0;//w ww. jav a 2 s . c o m if (count <= 0) count = 10; // Armamos el filtro de descendencia String parentFilter = "("; if (includeChilds) { for (String parentID : parents) { if (!parentID.endsWith(".")) parentID += "."; parentFilter += " terminos.id LIKE '" + parentID + "%' OR"; } } else { for (String parentID : parents) { parentFilter += " relaciones.id.idTermino1 = '" + parentID + "' OR"; } } if (includeSelf) { for (String parentID : parents) { if (parentID.endsWith(".")) parentID = parentID.substring(0, parentID.length() - 1); parentFilter += " terminos.id LIKE '" + parentID + "' OR"; } } //Sacamos el ultimo OR parentFilter = parentFilter.substring(0, parentFilter.length() - 2) + ")"; String sql = "SELECT terminos " + "FROM JerarquiasTermino AS terminos, JerarquiasRelaciones AS relaciones " + "WHERE terminos.id = relaciones.id.idTermino2 AND relaciones.tipoRelacion = 1 " + "AND LOWER(terminos.nombreEs) LIKE LOWER(:filtro) AND " + parentFilter; //Agrego el orden sql = sql + " ORDER BY terminos.nombreEs ASC"; // System.out.println(sql); EntityManager em = JerarquiasTermino.entityManager(); TypedQuery<JerarquiasTermino> q = em.createQuery(sql, JerarquiasTermino.class); q.setParameter("filtro", "%" + text + "%"); q.setFirstResult(start); q.setMaxResults(count); return q.getResultList(); }
From source file:ar.edu.unlp.sedici.sedici2003.model.TesaurosTermino.java
public static List<TesaurosTermino> findAll(String text, String[] parents, boolean includeChilds, int start, int count) { //if (text == null || text.length() == 0) throw new IllegalArgumentException("The text argument is required"); if (parents == null || parents.length == 0) throw new IllegalArgumentException("The parents argument is required"); if (start < 0) start = 0;//from w w w . j a v a2s .co m if (count <= 0) count = 60; // Armamos el filtro de descendencia String parentFilter = "("; if (includeChilds) { for (String parentID : parents) { if (!parentID.endsWith(".")) parentID += "."; parentFilter += " terminos.id LIKE '" + parentID + "%' OR"; } } else { for (String parentID : parents) { parentFilter += " relaciones.id.idTermino1 = '" + parentID + "' OR"; } } //Sacamos el ultimo OR parentFilter = parentFilter.substring(0, parentFilter.length() - 2) + ")"; String sql = "SELECT terminos " + "FROM TesaurosTermino AS terminos, TesaurosRelaciones AS relaciones " + "WHERE terminos.id = relaciones.id.idTermino2 AND relaciones.id.tipoRelacion = 1 " + "AND LOWER(terminos.nombreEs) LIKE LOWER(:filtro) AND " + parentFilter; //Agrego el orden sql = sql + " ORDER BY terminos.nombreEs ASC"; EntityManager em = TesaurosTermino.entityManager(); TypedQuery<TesaurosTermino> q = em.createQuery(sql, TesaurosTermino.class); if (text != null || text.length() != 0) { q.setParameter("filtro", "%" + text.trim() + "%"); } q.setFirstResult(start); q.setMaxResults(count); return q.getResultList(); }
From source file:com.clustercontrol.infra.util.QueryUtil.java
public static boolean isInfraFileReferredByFileTransferModuleInfoEntity(String fileId) { HinemosEntityManager em = new JpaTransactionManager().getEntityManager(); TypedQuery<FileTransferModuleInfo> query = em.createNamedQuery("FileTransferModuleInfoEntity.findByFileId", FileTransferModuleInfo.class); query.setParameter("fileId", fileId); query.setMaxResults(1); return !query.getResultList().isEmpty(); }
From source file:ar.edu.unlp.sedici.sedici2003.model.Personas.java
public static List<Personas> findPersonasesByApellidoYNombre(String apellido, String nombre, int start, int count) { if (apellido == null || apellido.length() == 0) apellido = ""; if (nombre == null) nombre = ""; if (start < 0) start = 0;/*from w w w.j a v a 2 s. co m*/ if (count <= 0) count = 20; apellido = Personas.convertirParaQuery(apellido); nombre = Personas.convertirParaQuery(nombre); String where = Personas.generateCondition(apellido, nombre); EntityManager em = Personas.entityManager(); TypedQuery<Personas> q = em.createQuery( "SELECT o FROM Personas AS o " + where + " ORDER BY o.apellido, o.nombre ASC", Personas.class); if (apellido.length() != 0) q.setParameter("apellido", apellido); if (nombre.length() != 0) q.setParameter("nombre", nombre); q.setFirstResult(start); q.setMaxResults(count); return q.getResultList(); }
From source file:net.groupbuy.dao.impl.AreaDaoImpl.java
public List<Area> findRoots(Integer count) { String jpql = "select area from Area area where area.parent is null order by area.order asc"; TypedQuery<Area> query = entityManager.createQuery(jpql, Area.class).setFlushMode(FlushModeType.COMMIT); if (count != null) { query.setMaxResults(count); }//from ww w. j av a 2s . c o m return query.getResultList(); }
From source file:org.antbear.jee.wicket.persistence.PersonService.java
public Iterator<Person> iterator(int first, int count) { TypedQuery<Person> query = em.createNamedQuery("person.findall", Person.class); query.setFirstResult(first);/* www . j a va 2s . c o m*/ query.setMaxResults(count); return query.getResultList().iterator(); }
From source file:csns.model.academics.dao.jpa.CourseDaoImpl.java
@Override public List<Course> searchCourses(String term, int maxResults) { TypedQuery<Course> query = entityManager.createNamedQuery("course.search", Course.class); if (maxResults > 0) query.setMaxResults(maxResults); return query.setParameter("term", term).getResultList(); }
From source file:com.costrategix.user.repository.JpaUserDao.java
public List<User> getAllList(int recordsPerPage, int pageNumber) { TypedQuery<User> query = em.createQuery("SELECT u FROM User u", User.class); query.setFirstResult(pageNumber * recordsPerPage); query.setMaxResults(recordsPerPage); return query.getResultList(); }
From source file:csns.model.academics.dao.jpa.ProgramDaoImpl.java
@Override public List<Program> searchPrograms(String term, int maxResults) { TypedQuery<Program> query = entityManager.createNamedQuery("program.search", Program.class); if (maxResults > 0) query.setMaxResults(maxResults); return query.setParameter("term", term).getResultList(); }
From source file:csns.model.academics.dao.jpa.ProjectDaoImpl.java
@Override public List<Project> searchProjects(String term, int maxResults) { TypedQuery<Project> query = entityManager.createNamedQuery("project.search", Project.class); if (maxResults > 0) query.setMaxResults(maxResults); return query.setParameter("term", term).getResultList(); }