Is there an incompatibility between those 2?
I have a n + 1 issue that I try to solve using the proprietary hibernate @BatchSize annotation.
public class Master{
@OneToMany(fetch = FetchType.LAZY, mappedBy = "master", orphanRemoval = true, cascade = CascadeType.ALL)
@BatchSize(size=100)//how many item collections we want to load from <b>other<b> Masters currently in the PC
private Set<Detail> details;
}
public class Detail{
private Master master;
}
case 1
List<Master> masters = getMastersFromJPACriteria(complexParams);
assert(masters.size() == 3);
masters.get(0).getDetails().size();
It should trigger the batch collection load of details :
SELECT * FROM DETAIL WHERE MASTER_ID IN (1,2,3)
But I have (N+1 issue):
SELECT * FROM DETAIL WHERE MASTER_ID = 1
case 2
However if I'm doing:
m1 = entityManager.find(Master.class,1L);
entityManager.find(Master.class,2L);
entityManager.find(Master.class,3L);
m1.getDetails().size();
It correctly triggers :
SELECT * FROM DETAIL WHERE MASTER_ID IN (1,2,3)
I don't understand why in case 1 the detail collections are not batch loaded.
Env: Wildfly 8.2.0.Final with Hibernate 4.3.7