. , ( ...).
, , , db ( psuedo SQL/HQL):
1) :
select sum(score)/count from reviews where product_id = ?
2) .
select product_name, sum(r.score)/count(r.score)
from products p
join reviews r
group by product_name
, - product_id .
, HQL, . , .
show_sql TestTestTest, , hibernate / .