Hi,
I've got a problem with a @ManyToOne and @OneToMany Annotation.
@Entity
@Table(name = "MYT_Team")
public class Team extends Named implements Serializable {
...
@OneToMany(mappedBy = "team", cascade = CascadeType.ALL, fetch = FetchType.EAGER, targetEntity = Player.class)
private Set<Player> players = new HashSet<Player>();
...
}
@Entity
@Table(name = "MYT_Player")
public class Player extends Human {
...
@ManyToOne(fetch = FetchType.EAGER)
private Team team;
...
}
I created a JUnit test for this and persisted the team and than the players. On database everthing looks fine. When i then load the team I allways get an empty Set. I also tried to call .size() on the set to force the loading and I tried it with an @JoinTable and @JoinCOlumn annotation. Nothing is working. In some cases {IndirectSet: not instantiated} is written inside of the set.
A Similar issue was discussed here: stackoverflow.com/questions/8301820/onetomany-relationship-is-not-working without any solution.
Does somebody have an idea how to fix this bug?
kind regards
Lars