If bytecode-enhancement is disabled, the lazy field with OneToOne association is not resolved. However if bytecode-enhancement is enabled, the lazy field is resolved(hibernate sends an additional sql statment to fetched the associated object).
The configuration of hibernate-enhance-maven-plugin is below
test case project with db ddl is attached. Please run JPAUnitTestCase to reproduce this issue.
JDK 1.8.0_131
postgresql 9.4.1212
This issue still happens on 5.2.17 and it also affect fields annotated with @ManyToOne. We have updated from 4.3 to 5.2 version and we have now queries taking 10 minutes when previously was 20 sec.
As the documentation is quite poor regarding the enhancer, is worth using it on 5.2?