Easy example.
Table Resource.
Table Line_A.
Table Line_B.
Join-Table Resource_Line_A
Join-Table Resource_Line_B
Resource for Line_A could not be attached to Line_B and vice versa.
If I want all resource attached to Line_A for year 2021, in native sql I can write
Select * from Resource r join Resource_Line_A rla on r.id = rla.resource_id join Line_A la on rla.line_a_id = la.id where la.year = 2021
In Java, with repository, I've lineARepository.findByYear(2021), but Hibernate show me this query
Select * from Resource r join Resource_Line_A rla on r.id = rla.resource_id join Line_A la on rla.line_a_id = la.id join Resource_Line_B rlb on r.id = rlb.resource_id join Line_B lb on rlb.line_b = lb.id where la.year = 2021
How I can avoid the useless join on Line_B table? All relationship are fetchtype.Lazy
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…