I have following entities:
Employee [@Id Long id, String name, @OneToOne Address branchAddress, @OneToOne Address homeAddress]
Address [@Id Long id, String street, String City, String zipcode, Country country]
Country [@Id Long id, String name, String currency, String isoCode]
My problem is when I try to load Employee, most of the time I don't want address. Fetching address fetches address and subsequenty country. These are extra queries that are executed everytime I load employee.
I have tried making @OneToOne(FetchType.LAZY) but doesn't work, it still pulls unneeded information.
How can i avoid fetching composite objects?
I would like the end result to not contain Address objects, Since it is needed once in 20 scenarios I can fetch them separately.
Any ideas, how to achieve this.
Thanks