Consider two related objects Bill
and BillItem
. All bills have several bill items.
Bill
class has getItems
which is configured as a OneToMany
with eager fetching.
If I select a set of bills (say for today for one customer) which returns 5 bills. Each bill has several bill items.
Would Hibernate use a join on tables Bill
and BillItem
to load the details in one shot? Or would hibernate use n+1 queries where n is the number of bills?
If using join queries is not the default behaviour, is there any way to configure Hibernate to use join in this case? Or would this require use of HQL and some custom coding to do the mapping?
Edit: I guess this has been covered here: JPA eager fetch does not join