Hi,
I'm working with hibernate-annotations-3.1beta5 with mySQL and I have this problem:
The class Player has an association (OneToMany) to field "stars" as follows:
Code:
@Entity(access = AccessType.FIELD)
public class Player {
...
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "owner")
private Collection<Star> stars;
}
The Star class has an association as follows:
Code:
@Entity(access = AccessType.FIELD)
public class Player {
...
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "owner")
private Player owner;
}
Also, the class Player has a method who adds a star to the collection (and initializates if null), like this:
Code:
public void addStar(Star star) {
star.setOwner(this);
getStars().add(star);
}
Later, when is needed, I call session.save(player)... it inserts Player, but no updates the "star" object in "stars" collection...
Does anybody can help me?
Thanks, and sorry for my awful english :)