Hibernate关系映射

2021-07-12 20:05

阅读:717

标签:false   ber   nat   value   reference   ignore   一对多   class   onetomany   

1.一对多,多字段

@JsonIgnore
    @OneToMany(mappedBy = "abc",cascade={CascadeType.PERSIST},fetch=FetchType.LAZY)
    private Set entity;
@ManyToOne(optional = true,fetch = FetchType.LAZY)
    @JoinColumnsOrFormulas(value={
    @JoinColumnOrFormula(column=@JoinColumn( name = "id" ,referencedColumnName = "id" ,insertable =false, updatable = false)),
    @JoinColumnOrFormula(column=@JoinColumn( name = "tid" ,referencedColumnName = "tid" ,insertable =false, updatable = false))})
    private ABC abc;

2.一对一,多字段

@JsonIgnore
    @OneToOne(optional = true,fetch = FetchType.LAZY)
    @JoinColumns(value={
            @JoinColumn(name="id",referencedColumnName="id",insertable =false, updatable = false),
            @JoinColumn(name="uid",referencedColumnName="uid",insertable =false, updatable = false)})
    private Entity entity;

 

Hibernate关系映射

标签:false   ber   nat   value   reference   ignore   一对多   class   onetomany   

原文地址:http://www.cnblogs.com/margin-gu/p/7081017.html


评论


亲,登录后才可以留言!