Use the setMaxResults method from the Java persistence API Query

Example:

@PersistenceContext(unitName="myPersistenceUnit")
   private EntityManager em;

   private int maxRecords = 100;
  
   public void getNextItems() {
        Query q = em.createQuery("select object(o) from Item as o");
        q.setMaxResults(maxRecords);
        items= q.getResultList();
   }

 

0
0
0
s2smodern