Hibernate One-To-One Mapping

when one entity is inside the another-one entity it is known as One-2-One Mapping.

 

 

 

For that we will use the following annotation.
@OneToOne:

Target:
Fields (including property get methods)
Defines a single-valued association to another entity that has one-to-one multiplicity. It is not normally necessary to specify the associated target entity explicitly since it can usually be inferred from the type of the object being referenced. If the relationship is bidirectional, the non-owning side must use the mappedBy element of the @OneToOne annotation to specify the relationship field or property of the owning side. 
The @OneToOne annotation may be used within an embeddable class to specify a relationship from the embeddable class to an entity class.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s