I've got a @ManyToMany association:
Code:
@ManyToMany(fetch=FetchType.EAGER)
@JoinTable( name="route_stations",
joinColumns=
@JoinColumn(name="routeID", referencedColumnName="id"),
inverseJoinColumns=
@JoinColumn(name="stationID", referencedColumnName="id") )
@IndexColumn(name="stationIndex")
private ArrayList<Station> stations = new ArrayList<Station>();
When I call the following code, it always returns with a null Station list:
Code:
String sql = "SELECT r.* FROM routes r INNER JOIN route_stations r_s ON r_s.routeID=r.id INNER JOIN stations s ON s.id=r_s.stationID WHERE s.id=1";
Query query = em.createNativeQuery( sql, Route.class );
What am I doing wrong? How do I get hibernate to eagerly load the station list for each route? I've even tried "SELECT r.*,rs.*..." Interestingly, the query manages to load the plain @OneToOne @Join association(s).