One of our model object in our application has many fields configured to be eagerly fetched like so:
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "field")
public Field getField() {
return this.field;
}
However I sometime do not need these information, which slow down my queries for nothing. I cannot change the behaviour and use FetchType.LAZY
instead as I've no idea what will be the impact on the whole application (legacy...). Is there a way to simply tell hibernate
to fetch nothing, except if it is specified in the query?