My problem is very simple, but I donβt know how to make Hibernate the way I want: - MainTable table has many-2-One with ParentTable (with 100 rows). MainTable points to m = 26 lines of 100 lines in ParentTable
@ManyToOne(fetch = FetchType.EAGER) @JoinColumn(name = "PARENT_ID") @Fetch(FetchMode.JOIN)
When I just request "from MainTable"
it will generate 26 + 1 queries
When I track requests, the first request only loads PARENT_ID, using 26 subsequent requests. I guess it should have a way to load the whole PARENT_TABLE into the 1st query.
Please help by suggesting that:
- FetchType.EAGER is MUST
- Using from MainTable mt left join fetch mt.parent parent is fine, but we have a lot of associations
source share