[Joint primary key]
>>>> Configuration method: XML:
1. Create a primary key entity class for studentpk separately in student
2. Configuration:
<composite-id name="studentPK"> <key-property name="name" column="username" /> <key-property name="nickname" column="nickname" /> </composite-id>
>>>> Annotation method: Annotation
1. Create a teacherpk primary key entity class separately in teacher
2. Annotation
** Annotation Method 1: [one annotation] ※common
<1>
@EmbeddedIdpublic TeacherPk getTeacherPk()
<2> the primary key class implements the serializable interface + overwrites the hashcode and equals methods.
TeacherPk implements Serializable{ @Override public int hashCode() @Override public boolean equals(Object obj)}
** Annotation Method 2: [two annotations]
<1>
@Embeddablepublic class TeacherPk implements Serializable
@Idpublic TeacherPk getTeacherPk()
<2> same as above