Hello,
I am using Criteria API for fetching data. Say we have simple Entity:
@Table(name="A") public class A { @id @Column(name = "id") private long id;
@Column(name="Description", nullable=false, length=20) private String description; }
This is code for fetching data: Criteria criteria = session.createCriteria( A.class.getName()).setFirstResult(offset * maxResults).setMaxResults(maxResults); criteria.addOrder(Order.asc("id")); return criteria.list();
When i use this code i can see that one select is generated for every entity by hibernate (in this case offset number of selects). When application connects to database across network this introduces delay. Is there any way to select all entities in one select with Criteria? What is solution to optimize performances in this case?
Best regards.
|