Hibernate version:3.2
Hey all
I'm having some difficulties with a HQL statement. I am trying to fetch a collection for a movie with the following query:
Code:
from Movie as m
inner join fetch m.movieViewStatistic
inner join fetch m.user
left join fetch m.comments
where m.isActive = 1 and
m.normalizedTitle = ?
The problem is that it will return a list of 56 movies instead of just one unique result. The movie in question has 56 comments so I'm guessing Hibernate returns one Movie for each Comment the movie has. If I leave out the "left join fetch m.comments" I will receive a unique result. The list of the 56 movies all have their comments initialized so it is fetching the collection properly, but why is it returning 56 results?
mapping:
Code:
Movie.hbm.xml
<set name="comments" cascade="all" order-by="created desc">
<key column="movie_id" />
<one-to-many class="com.myapp.model.MovieComment" />
</set>
MovieComment.hbm.xml
<many-to-one
name="movie"
column="movie_id"
not-null="true"
/>
Thanks!