我有两张 table bo_operator
和hist_bo_operator_password
带外键id_operator bigint REFERENCES bo_operator(id)
。
在 hist_bo_operator_password
一个密码有多个id_operator
。现在我想将所有这些值放入 List<String>
在 Spring Boot 应用程序中。
到目前为止我已经:
@Entity
@Table(name="bo_operator")
@SecondaryTable(name = "hist_bo_operator_password", pkJoinColumns=@PrimaryKeyJoinColumn(name="id_operator", referencedColumnName="id"))
public class Operator {
public Operator(Long id) {
super();
this.id = id;
}
如何编写方法:
@Column(table="hist_bo_operator_password", name="password")
public List<String> getOldPasswords()
{
return
}
返回 hist_bo_operator_password
中的所有密码对于 id_operator
?
最佳答案
@ElementCollection 允许您定义非实体类的映射...或使用 @CollectionTable 定义表。
关于java - 从数据库获取 hibernate 中的 List<String>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46543085/