What is the difference between @Embedded annotation technique and @OneToOne annotation technique because in Embedded the java class contain “Has a” relationship in class and with the help of @Embedded annotation we persist the has a object in database. and in OneToOne relationship we also persist the has a object in database.
What is the difference between @Embedded annotation technique and @OneToOne annotation technique because in
Share
@OneToOne is for mapping two DB tables that are related with a one to one relationship. For example a Customer might always have one record in a Name table.
Alternatively if those name fields are on the Customer table (not in a separate table) then you might want an @embedded. On the face of it you could just add the name fields as standard attributes to the Customer entity but it can be useful if those same columns appear on multiple tables (for example you might have the name columns on a Supplier table).