My problem is very simple but I don't know how to make Hibernate does the way I want: - table MainTable have Many-2-One with ParentTable (with 100 rows). MainTable point to m=26 rows out of 100 rows in ParentTable
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "PARENT_ID")
@Fetch(FetchMode.JOIN)
When I simply query "from MainTable"
it will generate 26 + 1 queries
When I trace the queries, the 1st query only load PARENT_ID used by 26 later queries. I guess it should have the way to load the whole PARENT_TABLE in the 1st query..
Please help by assuming that:
- FetchType.EAGER is a MUST
- Using from MainTable mt left join fetch mt.parent parent is ok but we have many association