Uninitialized HibernateProxy mapped as NO_PROXY gets initialized when reloaded with enhancement-as-proxy enabled
Description
This bug affects the following combination:
enhancement-as-proxy is enabled;
a lazy to-one association is mapped with @LazyToOne(LazyToOneOption.NO_PROXY);
the association is with an entity of a Class that has subclasses;
the association is loaded as a HibernateProxy via EntityType#resolveIdentifier;
the same proxy is later re-loaded for another association or by Session#load or Session#getReference.
In EntityType#resolveIdentifier, when the HibernateProxy is returned by Session#internalLoad, it sets HibernateProxy#setUnwrap( true ) in this code.
Later, when the same HibernateProxy is retrieved from StatefulPersistenceContext by DefaultLoadEventListener#proxyOrLoad, it gets initialized by this code.
Activity
Former userNovember 7, 2019 at 6:02 AM
Fixed in 5.3 branch as well.
Former userOctober 15, 2019 at 5:48 PM
All known issues are resolved now.
Former userOctober 1, 2019 at 11:59 PM
Reopened because there is another case that is not working.
Former userOctober 1, 2019 at 10:36 PM
Fixed in master.
Steve EbersoleSeptember 30, 2019 at 10:48 PM
I think I was saying that some of the tests looked wrong because of the NO_PROXY value, specifically the ones to an entity with subclasses which are treated using traditional JDK proxies. IIRC we decided to allow specifying NO_PROXY on these associations even though technically it is just ignored. Longer term, iirc, we had discussed removing the need for NO_PROXY at all.
This bug affects the following combination:
enhancement-as-proxy is enabled;
a lazy to-one association is mapped with
@LazyToOne(LazyToOneOption.NO_PROXY)
;the association is with an entity of a
Class
that has subclasses;the association is loaded as a
HibernateProxy
viaEntityType#resolveIdentifier
;the same proxy is later re-loaded for another association or by
Session#load
orSession#getReference
.In
EntityType#resolveIdentifier
, when theHibernateProxy
is returned bySession#internalLoad
, it setsHibernateProxy#setUnwrap( true )
in this code.Later, when the same
HibernateProxy
is retrieved fromStatefulPersistenceContext
byDefaultLoadEventListener#proxyOrLoad
, it gets initialized by this code.