I have mapped an 1:N relation with a @OneToMany List, but when I access the list, the results are duplicated due to an OUTER JOIN. This is how the mapping looks like:
@Entity
public class Programmer
@ElementCollection(fetch=FetchType.EAGER)
@CollectionTable(name="emails", joinColumns=@JoinColumn(name="id", nullable=false))
@Column(name="email", nullable=false)
protected Set<String> emails = new HashSet<String>();
@OneToMany(mappedBy="programmer", fetch=FetchType.EAGER)
private List <Game> games = new ArrayList<Game>();
When I get the attribute with prog.getGames(), the results comes duplicated because the Hibernate SQL makes an OUTER JOIN:
from programmer
left outer join emails on programmer.id=emails.id
left outer join game on programmer.id=game.id
where programmer.id=?
Is there any solution without transforming the List into a Set? I need to get the games with prog.getGames(), can not use a custom HQL or Criteria.