Hello,
I am using Hibernate Criteria for retrieving data from database. I am using paging to show results (cause ClassA has ~13000 rows) so my method looks like:
Criteria criteria = session.createCriteria( ClassA.class.getName()).setFirstResult(offset * maxResults).setMaxResults(maxResults); ClassA has one many-to-many and one one-to-many relation.
I noticed that query is fast when database is on the same computer as application. But when i connect to remote database, it takes around minut to see first page (600 rows). However when i retrieve another 600 rows (from 600 to 1200) it is retrieved in couple seconds. Only first query is very slow. I tried to set fetch mode to JOIN and fetch type to EAGER for all associations but query is still very slow. I examined log file and i can see that hibernate is calling same query many times.
Can someone help me about this issue, what i am doing wrong?
I created similar query in MySQL browser and get results in few seconds.
Best regards.
|