当前位置:编程学习 > JAVA >>

OneToMany级联新增失败求解

主健实体P与外键实体F是一对多,用hibernate注解配置如下:
class P{

private Set<F> children;

@OneTOMany(cascade=CascadeType.ALL,targetEntity=F.class,fetch=FetchType.EAMGE)
@JoinColunm(name="F_Pid",referenceColunmName="P_id")
public Set<F> getChildren(){
 return children;
}

}
以上是凭借自己的记忆写的,要求在保存P时保存Set<F> children,在保存时失败,F中外键为NULL,求各位大神们帮帮忙,在网上找了好多人的帖子,都不行,小弟第一次接触hibernate,项目又非常紧张,没有时间细看,只能在项目中遇到什么学习什么,但是这个实在解决不了。
顺便说下,多对一时,多的一方保存时级联一的一方可以级联保存成功。 hibernate 级联  一对多 OneToMany --------------------编程问答-------------------- @OneToMany(mappedBy = "legalEntity")
    @JsonIgnore
    public List<ClientAccount> getAccounts() {
        return accounts;
    }
@ManyToOne
    @JoinColumn(name = "legal_entity_id")
    public ClientLegalEntity getLegalEntity() {
        return legalEntity;
    }
级联一般save就够了,其它最好不要级联,注解点进去看代码,有详细注释 --------------------编程问答-------------------- 试过了,不行,不知道出错在哪边,无语了
补充:Java ,  Java EE
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,