Hibernate关系映射
1.一对多,多字段
@JsonIgnore @OneToMany(mappedBy = "abc",cascade={CascadeType.PERSIST},fetch=FetchType.LAZY) private Set<Entity> 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;