The following are various methods to prevent eager loading of @OneToOne relationships
- Use @MapsId as described here - Tried this but didn't work
- Fake a @One-Many relationaship but this could lead to issues with complicated JPQL queries.
- @OneToOne(fetch=FetchType.LAZY, optional=false) - I don't have non-nullable items
- Buildtime Byte Code Instrumentation - Again, I don't have non-nullable one-one relationships and hence will again not work in my case.
As a result, I think only option1 and option2 are suitable ones in my case. I know this topic has been discussed well like here in this excellent discussion. But those answers are almost 5-8 years back and was wondering if there are new methods now.
I have the following specific questions
- What are the situations under which @MapsId wouldn't work ?
- Are there any other issues with faking a @One-Many relationship as mentioned in option 2 above
- Are there any new alternatives in the new versions of Hibernate ?