| For Lazy ManyToOne/OneToOne mapping we used to impelement the FieldHandled interface and use the FieldHandler up til version 4.3.11. After upgrading to 5.2.12, where the FieldHandler was replaced by the PersistentAttributeInterceptable the lazy annotated fields were loaded at the end of the transaction in the `flushIfNecessary` anyways. We managed to get it working by making the Transaction readonly, which was sufficient for our use case. An example for reproducing the problem can be found in https://github.com/NoUsername/springDataPlay/tree/hibernate-lazy-one-to-one-issue The log with the difference in the SQL statements is attached and shows the difference between Hibernate 4 and 5. |