jpa 父子节点映射记录:(加入条件station_code):
----------------------------------------------------------------------------
@OneToMany(fetch = FetchType.EAGER)
@JoinColumn(name = "parent_id", referencedColumnName = "rela_tree_id")
@JoinColumn(name = "station_code", referencedColumnName = "station_code")
private Set<StationInfRelaTree> children;
-----------------------------------------------------------------------------
@Entity
@Table(name = "b_stationinfrelatree")
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler", "fieldHandler"})
public class StationInfRelaTree implements Serializable {
@Id
@Column(length = 20, name = "id")
private String id;
@Column(length = 20, name = "rela_tree_id")
private String relaTreeId;
/**
* 上級
*/
@JsonIgnore
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "parent_id", referencedColumnName = "rela_tree_id")
private StationInfRelaTree parent;
// @OneToMany(fetch = FetchType.EAGER, mappedBy = "parent")
//@OrderBy(value = "code asc")
@OneToMany(fetch = FetchType.EAGER)
@JoinColumn(name = "parent_id", referencedColumnName = "rela_tree_id")
@JoinColumn(name = "station_code", referencedColumnName = "station_code")
private Set<StationInfRelaTree> children;
/**
* 车站名称
*/
@Column(length = 20, name = "station_name")
private String stationName;
/**
* 信息状态
*/
@Column(length = 1, name = "rela_tree_state")
private String relaTreeState;
/**
* 车站站码
*/
@Column(length = 20, name = "station_code")
private String stationCode;
标签:code,JoinColumn,name,映射,jpa,private,节点,station,id From: https://www.cnblogs.com/sensenh/p/17688020.html