| How to reproduce this bug? Download the attachment file "hibernate-5.zip", unzip it and run "mvn clean install" The test can't be passed(but if you delete the instrument task in the pom, it should be passed). (1) This bug only happens if the instrument task is enabled. (2) The instance of CollectionEntry is created and retained by the PersistenceContext during the querying, but It does not be assigned to the collection property of entity object immediately. When access the collection property at the first time, the method readObject of the FieldHandler which is injected by the instrument task of the current entity object can return the instance of collection, After the first accessing, the collection is forgot by FieldHandlder but the entity class dose not remember the collection so that the collection property of the entity object will become null when it's accessed again. Expected target: Not only fix this bug simply, the lazy collection properties mechanism should not depend on the FieldHandler injected by instrument task, like hibernte4. Nobody want to load all the lazy scalar properties(@Basic(fetch = FetchType.LAZY) when another lazy collection is loaded. |