I have two entities:
@Entity
public class Game implements Serializable{
@ManyToOne
@JoinColumn(name = "target_id")
protected GameObject target;
}
@Entity
public class GameObject implements Serializable {
@OneToMany(mappedBy = "target", cascade = CascadeType.ALL)
protected Collection<Game> games = new HashSet<Game>();
}
In one transaction i delete on of games from game object.
@Transactional
public void deleteEntity(Object entity) {
getEntityManager().remove(entity);
getEntityManager().flush();
}
After that, when I tries to load gameObject, it has deleted game in collection. This game has only id property correct, rest is null. What is wrong, why this game is still in coolection?