【发布时间】:2020-06-09 11:55:04
【问题描述】:
还有我的课TableOne.java:
@Table(name = "table_one")
@EntityListeners(AuditingEntityListener.class)
public class TableOne {
@Id
@GeneratedValue(generator = "UUID")
@GenericGenerator(
name = "UUID",
strategy = "org.hibernate.id.UUIDGenerator")
@Column(name = "id", unique = true, nullable = false, updatable = false)
private String id;
@CreatedDate
@Column(name = "created", nullable = false, updatable = false)
private LocalDateTime created;
@LastModifiedDate
@Column(name = "modified", nullable = false)
private LocalDateTime modified;
@Column(name = "status_desc")
private String statusDesc;
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(table = "callers")
private Party caller;
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(table = "callee")
private Party callee;
...getter/setter
}
还有Part.java:
@Entity
public class Party {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", unique = true, nullable = false, updatable = false)
private long id;
@Column(name = "desc")
private String desc;
@Column(name = "ip")
private String ip;
@Column(name = "port")
private int port;
}
TableOne.java 中的以下字段:caller、callee 包含相同的字段(id、desc、port、ip),所以我想将它们保存在两个不同的表中。例如在 callee 和 caller 表中。
我该怎么做?
【问题讨论】:
标签: java hibernate spring-data-jpa spring-data hibernate-mapping