A TestCase to reproduce the issue (based on the current master) can be pulled here: https://github.com/hibernate/hibernate-orm/pull/1976 It contains two test methods: testPersistOnAlreadyPersistentEntityWithUninitializedLazyCollection At first, one Invoice with two InvoiceLines is prepared and persisted followed by flush and clear. Then the Invoice is reloaded an a simple change is made to one of its attributes. Now session.persist() is called on the Invoice which unnecessarily leads to the initialization of the InvoiceLines. IMHO this is the most simple scenario to reproduce the issue. On the other hand it might be unrealistic because the Invoice is already connected to the session and thus a persist call is not really needed to flush the change. Which leads to the second test case: testPersistOnNewEntityRelatedToAlreadyPersistentEntityWithUninitializedLazyCollection In order to make the scenario more realistic and a session.persist()-call necessary, a new Receipt entity will be connected to the already persistent Invoice. Now the call to session.persist() on the Receipt leads to the initialization of the InvoiceLines. |