Hi,
I have a Flight and a Pilot Entity. I would like Hibernate to load the Pilot relationship eager using a JOIN,
however executing "select f from flight f order by f.id" I see one select for each Pilot returned by the query.
Any idea what the reason could be?
Thank you in advance, Clemens
Code:
@Entity
@SequenceGenerator(name="flight_seq", sequenceName="flight_id_seq", allocationSize=1)
public class Flight {
@Id
@Column(columnDefinition = "SERIAL")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator="flight_seq")
public Integer id;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name="pilotid", nullable=true, columnDefinition="INTEGER")
@Fetch(org.hibernate.annotations.FetchMode.JOIN)
Pilot pilot;
}
@Entity
@SequenceGenerator(name="pilot_seq", sequenceName="pilot_id_seq", allocationSize=1)
public class Pilot {
@Id
@Column(columnDefinition = "SERIAL")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator="pilot_seq")
public Integer id;
}