-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Loading Entity with List: @ManyToMany & createNativeQuer
PostPosted: Wed Mar 21, 2007 9:13 am 
Newbie

Joined: Mon Mar 12, 2007 11:12 am
Posts: 3
Location: Australia
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).


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.