person と country の 2 つのテーブルがあります。
国は、「シンガポール」、「アメリカ」など、すべての国を含むテーブルです。person はすべてのユーザーを含むテーブルであり、名前、居住国などを格納しています。
データベース テーブルは次のようになります。
person
person_id int PK
name varchar(20)
country_id int FK
country
country_id int PK
country varchar(20)
次のようなクラス ダイアグラムを作成しようとしています。しかし、Person クラス内の変数 Country に対してどのような関係を示せばよいかわかりません。
@Entity
@Table(name=person)
class Person{
@Id
@Column(name="person_id")
@GeneratedValue(strategy=GeneratedType.IDENTITY)
private int personId;
@Column(name="name")
private String name;
@ ?
private Country country;
// Accessor and Mutator
}
@Entity
@Table(name=country)
private Country{
@Id
@Column(name=country_id)
@GeneratedValue(strategy=GeneratedType.IDENTITY)
private int countryId;
@Column(name="country")
private String country;
// Accessor and Mutator
}