假设我在Parent-Child之间具有双向一对多关联,映射如下:
public class TradingAccount {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@OneToMany(mappedBy = "tradingAccount", cascade = CascadeType.ALL, orphanRemoval = true)
private List<UnderlyingPerTradingAccount> underlyingPerTradingAccounts;
@Version
private Long version;
}
和
public class UnderlyingPerTradingAccount {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne
private TradingAccount tradingAccount;
private Boolean enableBuy;
private Boolean enableSell;
}
现在当我更新TradingAccount这个例外时我得到例外:
对象引用未保存的瞬态实例 - 在刷新之前保存瞬态实例