It looks very similar to https://hibernate.atlassian.net/browse/HHH-12298 . The application code is:
String productsQuery = "SELECT product "
+ "FROM Product product "
+ "LEFT JOIN FETCH product.name productName "
+ "LEFT JOIN FETCH product.description productDescription ";
List<Product> products = entityManager.createQuery(productsQuery, Product.class).getResultList();
log.info(String.format("Products %d", products.size()));
The elements are marked as lazy but JOIN FETCH is used, the generated query is properly including them in a join but apparently individual SELECT queries are also generated. What is really weird is that we don't even try to load the data as we only access products.size(). It looks as if the data were loaded twice, once with a JOIN and the second time with subsequent selects. |