Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » @OneToMany Annotation problem (@OneToMany does not fetch list)
@OneToMany Annotation problem [message #899863] Thu, 02 August 2012 12:17 Go to previous message
Lars Drießnack is currently offline Lars Drießnack
Messages: 9
Registered: August 2012
Junior Member
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
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic:Noob Problem: ClientSession.getAccessors() returns null
Next Topic:Problem in using SQL Keyword in JPQL
Goto Forum:
  


Current Time: Sun May 19 15:13:34 EDT 2013

Powered by FUDForum. Page generated in 0.01963 seconds