object references an unsaved transient instance

出现异常的原因很简单,是因为Hibernate 关联映射的原因        网上的解决方式在xml,或者注解@ManyToOne上加上级联  都无效

纠结半天     在save/update时    其他表的赋了默认值版本号的值(本来该为空),导致出现异常

解决办法:

  栏目表(simpleChannel),图片表(img)

f(simpleChannel.getImg().getId==null){
    Picture img = simpleChannel.getImg();
    img=null;
    simpleChannel.setImg(img);
}

如果图片未传就将其设置为空 

OK

2017/09/11

相关文章:

  • 2021-08-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-05
  • 2022-12-23
  • 2021-10-05
  • 2022-12-23
猜你喜欢
  • 2021-05-28
  • 2022-12-23
  • 2022-02-27
  • 2022-12-23
相关资源
相似解决方案