这是我的代码
@OneToMany(mappedBy = "parentTest")
@Cascade(CascadeType.ALL)
List<LanguageRecord> records = new ArrayList<>();
我想要这样的东西
@OneToMany(mappedBy = "parentTest")
@Cascade(CascadeType.ALL)
List<Long> languageRecordsIds = new ArrayList<>();
如何通过ID而不是对象进行映射?
答案 0 :(得分:0)
this question被接受的答案回答了如何仅保留id引用。
要弄清特定问题的处理方式,您需要执行以下操作:
@ElementCollection
@CollectionTable(name = "LanguageRecordTable", joinColumns=(@JoinColumn(name="<Column name of field to select from in LanguageRecordTable>"))
@Column(name = "<Name of id field to join on in this table>")
List<Long> languageRecordsIds;