How to fix the Hibernate “object references an unsaved transient instance - save the transient instance before flushing” error

前端 未结 30 1727
既然无缘
既然无缘 2020-11-22 07:11

I receive following error when I save the object using Hibernate

object references an unsaved transient instance - save the transient instance before flushi         


        
30条回答
  •  感动是毒
    2020-11-22 07:33

    Or, if you want to use minimal "powers" (e.g. if you don't want a cascade delete) to achieve what you want, use

    import org.hibernate.annotations.Cascade;
    import org.hibernate.annotations.CascadeType;
    
    ...
    
    @Cascade({CascadeType.SAVE_UPDATE})
    private Set children;
    

提交回复
热议问题