Thank you for your comment. I just tried to also set enableLazyInitialization. But the "Child"-entity is still loaded, now even before the call to flush. Can you please reproduce that?
This is where the load happens:
2016-07-13 00:17:52,164 DEBUG org.hibernate.SQL - select parent0_.id as id1_1_0_, parent0_.child_id as child_id2_1_0_ from Parent parent0_ where parent0_.id=?
2016-07-13 00:17:52,177 DEBUG org.hibernate.SQL - select child0_.id as id1_0_0_ from Child child0_ where child0_.id=?
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 2.881 sec <<< FAILURE!
test(eu.pinske.test.LazyLoadTest) Time elapsed: 2.719 sec <<< ERROR!
java.lang.RuntimeException: INTERNAL_LOAD_LAZY:eu.pinske.model.Child#1
at eu.pinske.test.LazyLoadingListener.onLoad(LazyLoadingListener.java:13)
at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1213)
at org.hibernate.internal.SessionImpl.internalLoad(SessionImpl.java:1096)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:639)
at org.hibernate.type.EntityType.resolve(EntityType.java:431)
at org.hibernate.engine.internal.TwoPhaseLoad.doInitializeEntity(TwoPhaseLoad.java:151)
at org.hibernate.engine.internal.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:125)
at org.hibernate.loader.plan.exec.process.internal.AbstractRowReader.performTwoPhaseLoad(AbstractRowReader.java:238)
at org.hibernate.loader.plan.exec.process.internal.AbstractRowReader.finishUp(AbstractRowReader.java:209)
at org.hibernate.loader.plan.exec.process.internal.ResultSetProcessorImpl.extractResults(ResultSetProcessorImpl.java:133)
at org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:122)
at org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:86)
at org.hibernate.loader.entity.plan.AbstractLoadPlanBasedEntityLoader.load(AbstractLoadPlanBasedEntityLoader.java:167)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:4004)
at org.hibernate.event.internal.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:508)
at org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:478)
at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:219)
at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:262)
at org.hibernate.event.internal.DefaultLoadEventListener.doOnLoad(DefaultLoadEventListener.java:121)
at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:89)
at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1213)
at org.hibernate.internal.SessionImpl.access$1900(SessionImpl.java:203)
at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.doLoad(SessionImpl.java:2753)
at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.load(SessionImpl.java:2727)
at org.hibernate.internal.SessionImpl.find(SessionImpl.java:3333)
at org.hibernate.internal.SessionImpl.find(SessionImpl.java:3297)
at eu.pinske.test.LazyLoadTest.test(LazyLoadTest.java:31)