vladmihalcea / hypersistence-optimizer

Hypersistence Optimizer allows you to get the most out of JPA and Hibernate. By scanning your application configuration and mappings, Hypersistence Optimizer can tell you what changes you need to do to speed up your data access layer.
https://vladmihalcea.com/hypersistence-optimizer/
Apache License 2.0
318 stars 43 forks source link

SecondaryQueryEntityFetchingEvent is not triggered for bidirectional OneToOne associations #240

Closed vladmihalcea closed 6 months ago

vladmihalcea commented 7 months ago

When fetching a parent entity that has a bidirectional @OneToOne association, Hibernate can trigger a secondary query for the child entity even if the association is using the FetchType.LAZY strategy.

Newer versions of Hibernate can avoid this issue if the parent association is set to optional=false. However, for optional=true and for older Hibernate versions, the secondary query is triggered, and we should also trigger a SecondaryQueryEntityFetchingEvent.

vladmihalcea commented 6 months ago

Fixed.