2
我在Spring Roo中定义了两个实体之间的双向多对一关系。从非所有者一方更新双向多对一关系的实体
@RooEntity
public class Car {
@OneToMany(mappedBy="car")
private Set<Wheel> wheels = new HashSet<Wheel>();
}
@RooEntity
public class Wheel {
@ManyToOne
@JoinColumn (name = "wheels_fk")
private Car car;
}
所有者方面(车轮)的变化仍然存在。
当我尝试从Car实体更新任何东西时,它不起作用。
我该怎么办?
this.wheels.remove(w);和this.wheels.add(w);将不起作用,因为您需要会话和事务上下文来调用这些方法 – george