0
私はbo_operator
とhist_bo_operator_password
と2つのテーブルforeign keys id_operator bigint REFERENCES bo_operator(id)
を持っています。 hist_bo_operator_password
には、id_operator
のパスワードが多数あります。今私は春のブートアプリケーションのすべての値をList<String>
に持っていきたいと思います。 は、これまでのところ私が持っている:id_operator
ためhist_bo_operator_password
からすべてのパスワードを返すようにリストを取得<String>データベースから休止状態に
@Column(table="hist_bo_operator_password", name="password")
public List<String> getOldPasswords()
{
return
}
:
@Entity
@Table(name="bo_operator")
@SecondaryTable(name = "hist_bo_operator_password", [email protected](name="id_operator", referencedColumnName="id"))
public class Operator {
public Operator(Long id) {
super();
this.id = id;
}
にはどうすればメソッドを書くことができますか?
特に、オペレータと強く結びついている場合は、別のテーブルの1つの列に対して新しいクラスを追加する必要はありません。この列をOperatorクラスに入れたいのですが、1つのテーブル= 1つのエンティティというルールを壊していますか? – Michu93
'@ SecondaryTable'は、1つのエンティティの情報が2つのテーブルに分散されている「onetoone」関係のために主に使用されているので、これを行うことはできません。私はリンクされた答えで述べたように '@ ElementCollection'アノテーションを使う必要があると思います。 – g00glen00b
@ElementCollection \t @CollectionTable(名前= "hist_bo_operator_password"、joinColumns = @ JoinColumn(名前= "id_operator")) \t @Column(名= "パスワード") \t公共一覧 oldPasswords =新しいArrayListを(); は上記のような問題を解決しました –
Michu93