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