Try like this
String sql = "SELECT t FROM table t";
Query query = em.createQuery(sql);
query.setFirstResult(firstPosition);
query.setMaxResults(numberOfRecords);
List result = query.getResultList();
It should work
UPDATE*
You can also try like this
query.setMaxResults(1).getResultList();
More Related Contents:
- having an exception when saving oracle type object in some entity
- How can I make a JPA OneToOne relation lazy
- org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when ‘hibernate.dialect’ not set
- When and why JPA entities should implement the Serializable interface?
- Spring Boot – Cannot determine embedded database driver class for database type NONE
- JPA : How to convert a native query result set to POJO class collection
- Why does JPA have a @Transient annotation?
- Spring-Data-Jpa Repository – Underscore on Entity Column Name
- How to persist a property of type List in JPA?
- Handling soft-deletes with Spring JPA
- Getting Database connection in pure JPA setup
- Hibernate and no PK
- When does the JPA set a @GeneratedValue @Id
- JPA @OneToOne with Shared ID — Can I do this Better?
- annotation to filter results of a @OneToMany association
- Parameter in like clause JPQL
- Hibernate/JPA – annotating bean methods vs fields [duplicate]
- Is it possible to dynamically define column names in Hibernate / JPA?
- Hibernate: “Field ‘id’ doesn’t have a default value”
- How to use @Transactional with Spring Data?
- @Basic(optional = false) vs @Column(nullable = false) in JPA
- Hibernate native query – char(3) column
- HQL joined query to eager fetch a large number of relationships
- Clarifying terminology – What does “hydrating” a JPA or Hibernate entity mean when fetching the entity from the DB
- Setting a JPA timestamp column to be generated by the database?
- What properties does @Column columnDefinition make redundant?
- DAO and Service layers (JPA/Hibernate + Spring) [duplicate]
- org.hibernate.loader.MultipleBagFetchException: cannot simultaneously fetch multiple bags
- JPA Updating Bidirectional Association
- Does JPA support mapping to sql views?