Onetoone
Public classemployee implements serializable {...... @ Onetoone (cascade = cascadetype. All, orphanremoval = true, fetch = fetchtype. Lazy) @ joincolumn (name = "addr_id") Private Address ;... ...}
Manytoone
Public classemployee implements serializable {...... @ Manytoone (fetch = fetchtype. lazy) @ jointable (name = "emp_job", joincolumns = @ joincolumn (name = "emp_id"), inversejoincolumns = @ joincolumn (name = "title_id ")) // keys are connected to the primary keys column of the table joincolumns primary test master table, the inversejoincolumns primary test field, or the private jobtitle column of the primary keys column of the table generated by attention; @ manytoone (fetch = fetchtype. lazy) @ joincolumn (name = "manager_id") private employee manager ;... ...}
Onetoworkflow
Public classemployee implements serializable {...... @ Onetomany (mappedby = "manager") // The manager field private list <employee> managedemployees = newarraylist <employee> (); @ onetomany (mappedby = "owner ", cascade = cascadetype. all, orphanremoval = true) Private list <phonenumber> phonenumbers = newarraylist <phonenumber> (); @ onetoworkflow (cascade = cascadetype. all, orphanremoval = true) @ joincolumn (name = "emp_id") Private list <degree> degrees = newarraylist <de Gree> ();......}
Manytoyun
Public classemployee implements serializable {...... @ Manytomany // @ jointable (name = "proj_emp", joincolumns = @ joincolumn (name = "emp_id"), inversejoincolumns = @ joincolumn (name = "proj_id ")) private list <project> projects = newarraylist <project> ();... ...}
Joint primary key ing
Manytoone onetow.manytoyun ing, And the jointable ing will show the joint primary key, that is, the double primary key.