Hello,
I’m migration an application from 5.5.8 to 6.2.1 and I’m running into a StackOverflowError
when loading objects using @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
and @Proxy(lazy = false)
Proxies were disabled on these classes to get around the issue that sometimes an instance was a proxy and an instanceof
test wasn’t working as expected.
The entities have several levels of inheritance and are connected to each other with associations.
This was all fine but when upgrading to Hibernate 6 it seems like the behavior for loading associations (with at the same time proxies disabled) has changed.
The stacktrace looks like this (repeated multiple times):
at org.hibernate.sql.results.graph.entity.internal.BatchInitializeEntitySelectFetchInitializer.resolveInstance(BatchInitializeEntitySelectFetchInitializer.java:74)
at org.hibernate.sql.results.internal.InitializersList.resolveInstances(InitializersList.java:88)
at org.hibernate.sql.results.internal.StandardRowReader.coordinateInitializers(StandardRowReader.java:110)
at org.hibernate.sql.results.internal.StandardRowReader.readRow(StandardRowReader.java:87)
at org.hibernate.sql.results.spi.ListResultsConsumer.consume(ListResultsConsumer.java:179)
at org.hibernate.sql.results.spi.ListResultsConsumer.consume(ListResultsConsumer.java:33)
at org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl.doExecuteQuery(JdbcSelectExecutorStandardImpl.java:362)
at org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl.executeQuery(JdbcSelectExecutorStandardImpl.java:168)
at org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl.list(JdbcSelectExecutorStandardImpl.java:93)
at org.hibernate.sql.exec.spi.JdbcSelectExecutor.list(JdbcSelectExecutor.java:31)
at org.hibernate.loader.ast.internal.SingleIdEntityLoaderDynamicBatch.load(SingleIdEntityLoaderDynamicBatch.java:140)
at org.hibernate.loader.ast.internal.SingleIdEntityLoaderDynamicBatch.load(SingleIdEntityLoaderDynamicBatch.java:58)
at org.hibernate.persister.entity.AbstractEntityPersister.doLoad(AbstractEntityPersister.java:3367)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3357)
at org.hibernate.event.internal.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:602)
at org.hibernate.event.internal.DefaultLoadEventListener.loadFromCacheOrDatasource(DefaultLoadEventListener.java:588)
at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:557)
at org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:550)
at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:202)
at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:241)
at org.hibernate.event.internal.DefaultLoadEventListener.doOnLoad(DefaultLoadEventListener.java:106)
at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:78)
at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:138)
at org.hibernate.internal.SessionImpl.fireLoadNoChecks(SessionImpl.java:1231)
at org.hibernate.internal.SessionImpl.internalLoad(SessionImpl.java:1075)
Can you please advise if that’s expected to happen (and we should stop disabling proxies) or if that might be a bug?
I’ve seen that the Proxy annotation was deprecated in 6.2 but it doesn’t elaborate on the reasons (or replacement).