【发布时间】:2018-11-24 10:04:36
【问题描述】:
我有两个共享一个公共键的表。我想要的是,当我为第一个表加载类时,我还会获得与第二个表对应的类列表,它们共享密钥。
更具体地说:tableA 的 id (id1) 存在于 tableB 的多个条目中。但是,tableB 使用复合键,并使用 id1 和 id2 作为键。
我想要实现的是,当表 A 的 POJO 被加载时,我还得到表 B 的所有条目,其中表 A 中的 id1 等于表 B 中的 id1。类似于:
public class TableA {
private String id1;
private List<TableB> list; // where id1 in tableA == id1 in tableB
}
table A id column:
id1
table B composite id:
id1 // same as for tableA
id2
【问题讨论】:
标签: sql hibernate jpa hibernate-mapping