Files
spring-data-demo/pagination/output/12-collection-fetch-paging-7.4.13.Final.txt

26 lines
2.2 KiB
Plaintext

Hibernate ORM: 7.4.13.Final
# 25 books, 6 of them with 2 reviews each (12 joined rows). Page of 2 products, join fetch p.reviews.
## method 8: @Query("select p from Product p join fetch p.reviews where ...")
select p1_0.id,p1_0.category,p1_0.name,p1_0.price,r1_0.product_id,r1_0.id,r1_0.rating from (select p1_0.id,p1_0.category,p1_0.name,p1_0.price from product p1_0 where p1_0.category=? and exists(select 1 from review r1_0 where p1_0.id=r1_0.product_id) order by p1_0.id offset ? rows fetch first ? rows only) p1_0(id,category,name,price) join review r1_0 on p1_0.id=r1_0.product_id order by p1_0.id
select count(*) from product p1_0 join review r1_0 on p1_0.id=r1_0.product_id where p1_0.category=?
products on the page: [book-1, book-2], reviews loaded on them: 4
entities held by the persistence context: 6
HHH90003004 (applying in memory) logged: false
totalElements reported: 12 (products that actually have reviews: 6)
## method 8b: the same query with countQuery = "select count(distinct p) ..."
select count(distinct p1_0.id) from product p1_0 join review r1_0 on p1_0.id=r1_0.product_id where p1_0.category=?
totalElements reported: 6, totalPages: 3
## method 8c: @EntityGraph(attributePaths = "reviews") on a derived query, page of 4
select p1_0.id,p1_0.category,p1_0.name,p1_0.price,r1_0.product_id,r1_0.id,r1_0.rating from (select p1_0.id,p1_0.category,p1_0.name,p1_0.price from product p1_0 where p1_0.category=? order by p1_0.id offset ? rows fetch first ? rows only) p1_0(id,category,name,price) left join review r1_0 on p1_0.id=r1_0.product_id order by p1_0.id
select count(*) from product p1_0 where p1_0.category=?
rows: 4, totalElements: 25, entities held by the persistence context: 12
## methods 9a + 9b: page the ids, then fetch the reviews for exactly those ids
select p1_0.id from product p1_0 where p1_0.category=? order by p1_0.id fetch first ? rows only
select count(*) from product p1_0 where p1_0.category=?
select distinct p1_0.id,p1_0.category,p1_0.name,p1_0.price,r1_0.product_id,r1_0.id,r1_0.rating from product p1_0 join review r1_0 on p1_0.id=r1_0.product_id where p1_0.id in (?,?) order by p1_0.id
ids on the page: [1, 2], products fetched: 2, reviews fetched: 4