Embedded Object
1. @embedded + @embeddable
2. inner component doesn have @embedded Tag is considered to be default, and Hibernate will search embeddable object for it.
Hibernate mapping
1. One to One
1.1 mapping primary key:
@OneToOne
@PrimaryKeyJoinColumn
1.2 use foreign key;
@OneToOne
@JoinColumn(name="user")
@OneToOne(mappedBy = "user")
To declare a side as not responsible for the relationship, the attribute mappedBy is used. mappedBy refers to the property name of the association on the owner side. In our case, this is passport . As you can see, you don't have to (must not) declare the join column since it has already been declared on the owners side.
2. ManyToOne - bidirection
@ManyToOne
@JoinColumn(name = "user")
@OneToMany(mappedBy="user")
To enable property lazy loading, the class must be bytecode instrumented.
google " bytecode instrument"