omid haghighatgoo
omid haghighatgoo

Reputation: 332

paging huge data result in jpa

I have a database with huge data , when I query something it returns lots of data that not only it takes lots of time but also it takes lots of memory and sometimes application faild

I'm working with hibernate jpa and EJB. I want to know that if JPA does have something to handle this problem or I must my self handle this thing

I want some thing that paging huge data in to for example to 20 rows per page that also I can say to it show for example page 15 .

Upvotes: 0

Views: 569

Answers (2)

Balaji Reddy
Balaji Reddy

Reputation: 5700

I got your query. From my understanding Hibernate/JPA follows connected architecture(since it uses resultset underneath) which will not pull all the required dates into memory but it will hold the reference on the database table... Obviously u have options to fetch specific number of rows as mentioned in other comments but i personally recommend you to understand how does it (partial fetch) works.....

Cheers!

Upvotes: 1

V G
V G

Reputation: 19002

Of course it is possible to paginate the results in JPA. If you use Queries, take a look at the java docs, specifically at the methods setFirstResult() and setMaxResults().

Something similar is possible with Criteria API, simply check the documentation.

Upvotes: 2

Related Questions