Hibernate级联操作

来源:互联网 发布:mac炉石记牌器 编辑:程序博客网 时间:2024/06/08 04:22

测试一对多级联操作时报错

org.hibernate.TransientObjectException : object references an unsaved transient instance - save the transient instance before flushing: com.xzp.onetomany.Order

即持久态对象关联了瞬时态对象,瞬时态对象不可以被保存,在Hibernate的关联关系这种提供了级联保存的支持。


解决方法:

在持久态对象的映射文件Customer.hbm.xml中的<set>标签添加    cascade="save-update"

原创粉丝点击