I have created two entities Customer and Customer Record.
//customer class
@OneToOne
@JoinColumn(name="CUSTREC_ID", unique=true)
CustomerRecord customerRecord;
//customer record class
@OneToOne(mappedBy="customerRecord")
Customer customer;
The purpose of mappedBy is to indicate the owner exists on the other side of the relationship. When I see my example and see that mappedBy is used as mappedBy="customerRecord", I see that it contradicts with the definition of mappedBy because the mapping is done on the customer side of the relationship and the value mentioned for the attribute in mappedBy is customer Record. If I follow the definition of mappedBy then it should have been mappedBy="customer" since that is the side holding the relationship. So what is wrong in my understanding?
Queries generated:
Hibernate: insert into CustomerRecord (customerRecordName, CustomerRecordId) values (?, ?)
Hibernate: insert into Customer (customerName, CUSTREC_ID, customerId) values (?, ?, ?)