save the transient instance before flushing



三张数据表的关系如下图 

save the transient instance before flushing_第1张图片


在java中如下写法报错(错误信息:save the transient instance before flushing):

 @OneToMany(fetch=FetchType.LAZY)  //这种情形会报错save the transient instance before flushing: elitel.szy.groundwater.entity.PlanLayer
 @JoinColumn(name="PLID")
 public List getLayers() {
  return layers;
 }
 public void setLayers(List layers) {
  this.layers = layers;
 }


将上述代码修改下,错误解决:


 @OneToMany(fetch = FetchType.LAZY , cascade=CascadeType.ALL)
 @JoinColumn(name="PLID")
 public List getLayers() {
  return layers;
 }
 public void setLayers(List layers) {
  this.layers = layers;
 }


但为什么如此改就可以解决问题,还不清楚。

你可能感兴趣的:(Bug解决方案)