I\'ve got the following query which I expect to run in a single select request:
@NamedQuery(name=Game.GET_GAME_BY_ID1,
query = \"SELECT g FROM Ga
The secondary queries come from:
@ManyToOne(fetch=FetchType.EAGER)
@Fetch(FetchMode.JOIN)
@JoinColumn(name="team_id2")
public Team getTeam2() {
return team2;
}
So, you need to:
Make all associations LAZY. By default, all @ManyToOne and @OneToOne associations are EAGER, so it's better to have them LAZY and only override the fetch plan on a query basis.
Remove the @Fetch(FetchMode.JOIN)
, which is essentially an EAGER fetch directive. In your case, not just the team2 property is fetched, but its players and skills as well.