HibernateProxy might need to be instantiated even with build-time enhancement

Description

In Quarkus we enforce build-time bytcode enhancement, and then configured Hibernate ORM to use org.hibernate.bytecode.internal.none.DisallowedProxyFactory (which I had created for this purpose - but apparently had not understood all implications).

We now have a reproducer able to produce the following stacktrace:

2020-01-09 10:41:52,827 INFO [org.hib.eve.int.DefaultLoadEventListener] (executor-thread-1) HHH000327: Error performing load command: org.hibernate.HibernateException: Generation of HibernateProxy instances at runtime is not allowed when the configured BytecodeProvider is 'none'; your model requires a more advanced BytecodeProvider to be enabled. at org.hibernate.bytecode.internal.none.DisallowedProxyFactory.getProxy(DisallowedProxyFactory.java:37) at org.hibernate.tuple.entity.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:713) at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:4971) at org.hibernate.event.internal.DefaultLoadEventListener.createProxy(DefaultLoadEventListener.java:427) at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:301) at org.hibernate.event.internal.DefaultLoadEventListener.doOnLoad(DefaultLoadEventListener.java:108) at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:74) at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:118) at org.hibernate.internal.SessionImpl.fireLoadNoChecks(SessionImpl.java:1168) at org.hibernate.internal.SessionImpl.internalLoad(SessionImpl.java:1033) at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:687) at org.hibernate.type.EntityType.resolve(EntityType.java:464) at org.hibernate.type.ManyToOneType.resolve(ManyToOneType.java:240) at org.hibernate.engine.internal.TwoPhaseLoad.doInitializeEntity(TwoPhaseLoad.java:226) at org.hibernate.engine.internal.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:160) at org.hibernate.loader.plan.exec.process.internal.AbstractRowReader.performTwoPhaseLoad(AbstractRowReader.java:255) at org.hibernate.loader.plan.exec.process.internal.AbstractRowReader.finishUp(AbstractRowReader.java:215) at org.hibernate.loader.plan.exec.process.internal.ResultSetProcessorImpl.extractResults(ResultSetProcessorImpl.java:137) at org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:105) at org.hibernate.loader.entity.plan.AbstractLoadPlanBasedEntityLoader.load(AbstractLoadPlanBasedEntityLoader.java:223) at org.hibernate.persister.entity.AbstractEntityPersister.doLoad(AbstractEntityPersister.java:4388) at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:4378) at org.hibernate.event.internal.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:569)

Activity

Show:

Sanne GrinoveroFebruary 10, 2020 at 10:34 AM

This was solved; adding some links for posterity as we had to make changes across projects:

In Hibernate ORM:

And in Quarkus:

 

Sanne GrinoveroFebruary 7, 2020 at 1:45 PM
Edited

This is now resolved, mostly by the combination of https://hibernate.atlassian.net/browse/HHH-13851 , https://hibernate.atlassian.net/browse/HHH-13850 , https://hibernate.atlassian.net/browse/HHH-13849#icft=HHH-13849 .

It still needs changes on the Quarkus side, to actually plug a custom ProxyFactoryFactory into the bootstrap registry; I'll send a PR to Quarkus but we need an Hibernate ORM release first.

PROJanuary 24, 2020 at 9:38 PM

Thanks a lot @Sanne !

grinning face with big eyes

Sanne GrinoveroJanuary 24, 2020 at 8:41 PM

Hi Rafael,

the good news is that I was just working on this right now slightly smiling face

Last week we had some brainstorming in the team, and I thought we had a good solution; sadly I just finished testing it, and it doesn’t work: it no longer allows me to compille to native images. I’m trying now to verify if I implemented it all correctly, as the exceptions is surprising me a bit.

 

PROJanuary 24, 2020 at 6:57 PM

Hi Hibernate Guys, any update on this ?

Fixed

Details

Assignee

Reporter

Components

Fix versions

Affects versions

Priority

Created January 9, 2020 at 10:55 AM
Updated February 10, 2020 at 10:34 AM
Resolved February 7, 2020 at 1:45 PM

Flag notifications