2
我有两个实体:JPA父子删除
@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>();
}
在一个交易我删除从游戏对象的游戏。
@Transactional
public void deleteEntity(Object entity) {
getEntityManager().remove(entity);
getEntityManager().flush();
}
之后,当我尝试加载gameObject时,它已删除集合中的游戏。此游戏只有id属性正确,其余为空。什么是错的,为什么这个游戏仍然在coolection?