Consider this simple association:
@Entity
public class Employee
{
@OneToMany(fetch=FetchType.LAZY)
private Set<Address> addresses;
}
Using this code the addresses are not fetched in the result:
Query query=entityManager.createQuery("select e from Employee e");
query.setHint("eclipselink.batch.type", "JOIN");
query.setHint("eclipselink.batch", "e.addresses");
List list=query.getResultList();
While in this one the addresses are fetched:
Query query=entityManager.createQuery("select e from Employee e");
query.setHint("eclipselink.join-fetch", "e.addresses");
List list=query.getResultList();
Why the batch fetch is not working in the first?
I'm using EclipseLink 2.5.1. I also tried the @BatchFetch
annotation and neither of those approaches did work.