I'm using JPA 2 in my project (eclipselink provider), and I have the following problem:
When I execute the following code:
em.createQuery("select t from " + entityName + " t where t.id = ?1"
).setParameter(1, id)
.setHint(QueryHints.REFRESH, HintValues.TRUE)
.setHint(QueryHints.REFRESH_CASCADE, CascadePolicy.CascadeAllParts)
.getSingleResult();
JPA generates tons of queries to fetch all dependent objects( i.e ~90 queries to fetch an entity). It there any way to force JPA to use joins instead of independent queries?