我有一个用弹簧启动写的应用程序,在Postgres上有3个表T1,T2和T3
t1 one2many映射与t2和t2 one2many与t3
如何将这些表合并为一个?模型和存储库是否保持不变?
T1的模型
tension: 0
T2的模型
@Entity
@Table(name = "maintenance_type")
@EntityListeners(AuditingEntityListener.class)
@JsonIgnoreProperties(value = { "createdAt", "updatedAt" }, allowGetters = true)
public class MaintenanceType implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@NotBlank
@Column(unique=true)
private String changeType;
@Column(nullable = false, updatable = false)
@Temporal(TemporalType.TIMESTAMP)
@CreatedDate
private Date createdAt;
@Column(nullable = false)
@Temporal(TemporalType.TIMESTAMP)
@LastModifiedDate
private Date updatedAt;
@OneToMany(mappedBy = "maintenanceType", cascade = CascadeType.ALL)
private Set<TierTwoQuestion> tierTwoQuestion;
public MaintenanceType() {
}
public MaintenanceType(Long id, String changeType) {
super();
this.id = id;
this.changeType = changeType;
}
public MaintenanceType(String changeType) {
super();
this.changeType = changeType;
}
public Set<TierTwoQuestion> getTierTwoQuestion() {
return tierTwoQuestion;
}
//
public void setTierTwoQuestion(Set<TierTwoQuestion> tierTwoQuestion) {
this.tierTwoQuestion = tierTwoQuestion;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getChangeType() {
return changeType;
}
public void setChangeType(String changeType) {
this.changeType = changeType;
}
public Date getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
public Date getUpdatedAt() {
return updatedAt;
}
public void setUpdatedAt(Date updatedAt) {
this.updatedAt = updatedAt;
}
}
我尝试在一个表中添加重新创建所有T1 T2 T3但未按预期工作的模型