Here is the details of problem statement:
Now, what I need is that:
- There should be OneToOne Mapping between Entities.
- Primary Key (and Foreign Key) are manually generated. I don’t this automatically generated.
- I create Employee and Address object, setup required fields and set just address in employee (not employee in address) employee.setAddress(address).
- When persisting employee object, it should save employee, and address and setup FK relation in Address table with Employee. I don’t need to save Address separately.
- Next, while retrieving data, I would like when getting Employee, Address should be lazily loaded.
- Also, another important point is Address field is optional wrt Employee. I mean, Every address will have exactly one Employee, but not all Employee will have address.