java.lang.AssertionError: null in resolveEntityInstance1

Hello,
Sometimes on our CI (never in production, never when running locally) we are getting the error:

java.lang.AssertionError: null
 	at org.hibernate.sql.results.graph.entity.internal.EntityInitializerImpl.resolveEntityInstance1(EntityInitializerImpl.java:1114) ~[hibernate-core-6.6.26.Final.jar:6.6.26.Final]

As you can see, we are using hibernate-core-6.6.26.Final.
The full stack trace is here:

Summary
java.lang.AssertionError: null
2025-09-17T16:20:11.2845544Z 	at org.hibernate.sql.results.graph.entity.internal.EntityInitializerImpl.resolveEntityInstance1(EntityInitializerImpl.java:1114) ~[hibernate-core-6.6.26.Final.jar:6.6.26.Final]
2025-09-17T16:20:11.2847976Z 	at org.hibernate.sql.results.graph.entity.internal.EntityInitializerImpl.resolveInstance(EntityInitializerImpl.java:1032) ~[hibernate-core-6.6.26.Final.jar:6.6.26.Final]
2025-09-17T16:20:11.2850325Z 	at org.hibernate.sql.results.graph.entity.internal.EntityInitializerImpl.resolveKey(EntityInitializerImpl.java:587) ~[hibernate-core-6.6.26.Final.jar:6.6.26.Final]
2025-09-17T16:20:11.2852486Z 	at org.hibernate.sql.results.graph.entity.internal.EntityInitializerImpl.resolveKey(EntityInitializerImpl.java:457) ~[hibernate-core-6.6.26.Final.jar:6.6.26.Final]
2025-09-17T16:20:11.2854103Z 	at org.hibernate.sql.results.graph.entity.internal.EntityInitializerImpl.resolveKey(EntityInitializerImpl.java:97) ~[hibernate-core-6.6.26.Final.jar:6.6.26.Final]
2025-09-17T16:20:11.2855485Z 	at org.hibernate.sql.results.graph.Initializer.resolveKey(Initializer.java:101) ~[hibernate-core-6.6.26.Final.jar:6.6.26.Final]
2025-09-17T16:20:11.2856933Z 	at org.hibernate.sql.results.graph.entity.internal.EntityInitializerImpl.resolveKeySubInitializers(EntityInitializerImpl.java:700) ~[hibernate-core-6.6.26.Final.jar:6.6.26.Final]
2025-09-17T16:20:11.2858900Z 	at org.hibernate.sql.results.graph.entity.internal.EntityInitializerImpl.resolveKey(EntityInitializerImpl.java:601) ~[hibernate-core-6.6.26.Final.jar:6.6.26.Final]
2025-09-17T16:20:11.2861120Z 	at org.hibernate.sql.results.graph.entity.internal.EntityInitializerImpl.resolveKey(EntityInitializerImpl.java:457) ~[hibernate-core-6.6.26.Final.jar:6.6.26.Final]
2025-09-17T16:20:11.2863291Z 	at org.hibernate.sql.results.graph.entity.internal.EntityInitializerImpl.resolveKey(EntityInitializerImpl.java:97) ~[hibernate-core-6.6.26.Final.jar:6.6.26.Final]
2025-09-17T16:20:11.2865491Z 	at org.hibernate.sql.results.internal.StandardRowReader.coordinateInitializers(StandardRowReader.java:235) ~[hibernate-core-6.6.26.Final.jar:6.6.26.Final]
2025-09-17T16:20:11.2867424Z 	at org.hibernate.sql.results.internal.StandardRowReader.readRow(StandardRowReader.java:141) ~[hibernate-core-6.6.26.Final.jar:6.6.26.Final]
2025-09-17T16:20:11.2869247Z 	at org.hibernate.sql.results.spi.ListResultsConsumer.readUnique(ListResultsConsumer.java:283) ~[hibernate-core-6.6.26.Final.jar:6.6.26.Final]
2025-09-17T16:20:11.2871054Z 	at org.hibernate.sql.results.spi.ListResultsConsumer.consume(ListResultsConsumer.java:195) ~[hibernate-core-6.6.26.Final.jar:6.6.26.Final]
2025-09-17T16:20:11.2872845Z 	at org.hibernate.sql.results.spi.ListResultsConsumer.consume(ListResultsConsumer.java:35) ~[hibernate-core-6.6.26.Final.jar:6.6.26.Final]
2025-09-17T16:20:11.2874895Z 	at org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl.doExecuteQuery(JdbcSelectExecutorStandardImpl.java:224) ~[hibernate-core-6.6.26.Final.jar:6.6.26.Final]
2025-09-17T16:20:11.2877304Z 	at org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl.executeQuery(JdbcSelectExecutorStandardImpl.java:102) ~[hibernate-core-6.6.26.Final.jar:6.6.26.Final]
2025-09-17T16:20:11.2879369Z 	at org.hibernate.sql.exec.spi.JdbcSelectExecutor.executeQuery(JdbcSelectExecutor.java:91) ~[hibernate-core-6.6.26.Final.jar:6.6.26.Final]
2025-09-17T16:20:11.2881049Z 	at org.hibernate.sql.exec.spi.JdbcSelectExecutor.list(JdbcSelectExecutor.java:165) ~[hibernate-core-6.6.26.Final.jar:6.6.26.Final]
2025-09-17T16:20:11.2882919Z 	at org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan.lambda$new$1(ConcreteSqmSelectQueryPlan.java:149) ~[hibernate-core-6.6.26.Final.jar:6.6.26.Final]
2025-09-17T16:20:11.2885254Z 	at org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan.withCacheableSqmInterpretation(ConcreteSqmSelectQueryPlan.java:439) ~[hibernate-core-6.6.26.Final.jar:6.6.26.Final]
2025-09-17T16:20:11.2887643Z 	at org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan.performList(ConcreteSqmSelectQueryPlan.java:359) ~[hibernate-core-6.6.26.Final.jar:6.6.26.Final]
2025-09-17T16:20:11.2889537Z 	at org.hibernate.query.sqm.internal.QuerySqmImpl.doList(QuerySqmImpl.java:380) ~[hibernate-core-6.6.26.Final.jar:6.6.26.Final]
2025-09-17T16:20:11.2891183Z 	at org.hibernate.query.spi.AbstractSelectionQuery.list(AbstractSelectionQuery.java:143) ~[hibernate-core-6.6.26.Final.jar:6.6.26.Final]
2025-09-17T16:20:11.2892655Z 	at org.hibernate.query.Query.getResultList(Query.java:120) ~[hibernate-core-6.6.26.Final.jar:6.6.26.Final]
2025-09-17T16:20:11.2894629Z 	at org.springframework.data.jpa.repository.query.JpaQueryExecution$CollectionExecution.doExecute(JpaQueryExecution.java:130) ~[spring-data-jpa-3.5.1.jar:3.5.1]
2025-09-17T16:20:11.2896767Z 	at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:93) ~[spring-data-jpa-3.5.1.jar:3.5.1]
2025-09-17T16:20:11.2898810Z 	at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:160) ~[spring-data-jpa-3.5.1.jar:3.5.1]
2025-09-17T16:20:11.2900670Z 	at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:148) ~[spring-data-jpa-3.5.1.jar:3.5.1]
2025-09-17T16:20:11.2902438Z 	at org.springframework.data.repository.core.support.RepositoryMethodInvoker.doInvoke(RepositoryMethodInvoker.java:170) ~[spring-data-commons-3.5.1.jar:3.5.1]
2025-09-17T16:20:11.2904376Z 	at org.springframework.data.repository.core.support.RepositoryMethodInvoker.invoke(RepositoryMethodInvoker.java:158) ~[spring-data-commons-3.5.1.jar:3.5.1]
2025-09-17T16:20:11.2906003Z 	at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:170) ~[spring-data-commons-3.5.1.jar:3.5.1]
2025-09-17T16:20:11.2907671Z 	at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:149) ~[spring-data-commons-3.5.1.jar:3.5.1]
2025-09-17T16:20:11.2909252Z 	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184) ~[spring-aop-6.2.8.jar:6.2.8]
2025-09-17T16:20:11.2910995Z 	at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:69) ~[spring-data-commons-3.5.1.jar:3.5.1]
2025-09-17T16:20:11.2912715Z 	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184) ~[spring-aop-6.2.8.jar:6.2.8]
2025-09-17T16:20:11.2914268Z 	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:380) ~[spring-tx-6.2.8.jar:6.2.8]
2025-09-17T16:20:11.2915918Z 	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119) ~[spring-tx-6.2.8.jar:6.2.8]
2025-09-17T16:20:11.2917451Z 	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184) ~[spring-aop-6.2.8.jar:6.2.8]
2025-09-17T16:20:11.2919112Z 	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:138) ~[spring-tx-6.2.8.jar:6.2.8]
2025-09-17T16:20:11.2920713Z 	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184) ~[spring-aop-6.2.8.jar:6.2.8]
2025-09-17T16:20:11.2922414Z 	at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:136) ~[spring-data-jpa-3.5.1.jar:3.5.1]
2025-09-17T16:20:11.2924316Z 	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184) ~[spring-aop-6.2.8.jar:6.2.8]
2025-09-17T16:20:11.2925847Z 	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:223) ~[spring-aop-6.2.8.jar:6.2.8]

Further down the stack is our business code which is using JpaRepository method findAll in a way:

@Override
    @Query("select distinct a from Account a "
            + "left join fetch a.X1 bb "
            + "left join fetch bb.X2 b "
            + "left join fetch bb.X3 hc "
            + "left join fetch a.x4 a2cp "
            + "left join fetch a.x5 c "
            + "left join fetch a.x6 ima "
            + "left join fetch a.x7 en "
            + "left join fetch a.x8 lh")
    List<Account> findAll();

Frame:
at xx.account.$Proxy295.findAll(Unknown Source) ~[na:na]

I did found some similar topics, like:
Assertion Error after updating from 6.4.4 to 6.6.1 - #4 by codylerum Solution: use newer version, I alreado do!

Jira Well, here some other loaded entities in transaction come into play? In our example we load all the accounts without any prior transaction logic. On a received message, we load all accounts and process them.

Could you guys help me with that? I cannot really get the debugger here as I have never reproduced it locally, but maybe we could do some additional logging as our CI is becoming more frequent with those errors (we do split tests on several runners, maybe there is some weird combination - tests use common Spring context, but should it matter? Hibernate caches only entities in transaction… )

Regards!

Please try updating to 6.6.29.Final first and report back if the problem persists. Are you using bytecode enhancement?
The assertion error is only thrown when assertions are enabled, which is the default when executing tests. That’s why you’re not seeing this in production.
The assertion that fails is trying to ensure an entity is being loaded by a particular EntityInitializer, but that expectation fails. The fact that it works in production, might indicate that the assertion/expectation is wrong or unnecessary, but without actually seeing a scenario that provokes an assertion error, it’s hard to say for sure.

Before the error, are there other logs that show data fetching from JDBC succeeds?

Can you share the entity model and exact query please? If Account has an association to another Account which you are left join fetching, that might be an indicator about what is going on. Maybe an account does a self reference? Or maybe the first row contains account 1 and the second row refers to this account 1 through an association? Information like that is vital to reconstruct what is going on.

I am also facing similar issue while I run test in our CI. error:

StackTrace

java.lang.RuntimeException: java.lang.AssertionError
at org.springframework.data.repository.core.support.RepositoryMethodInvoker$RepositoryFragmentMethodInvoker.lambda$new$0(RepositoryMethodInvoker.java:281)
at org.springframework.data.repository.core.support.RepositoryMethodInvoker.doInvoke(RepositoryMethodInvoker.java:170)
at org.springframework.data.repository.core.support.RepositoryMethodInvoker.invoke(RepositoryMethodInvoker.java:158)
at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:515)
at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:284)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:734)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:174)
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:149)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:69)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:380)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:138)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:165)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:223)
at jdk.proxy2/jdk.proxy2.$Proxy404.getAllByQual(Unknown Source)
at com.flotomate.service.base.base.FlotoBaseServiceImpl.searchByQualification(
.java:785)
at com.flotomate.service.base.reference.FlotoReferenceModelServiceImpl.searchByQualification(FlotoReferenceModelServiceImpl.java:81)
at jdk.internal.reflect.GeneratedMethodAccessor642.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:569)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:360)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:196)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:728)
at com.flotomate.service.formrule.FormRuleServiceImpl$$SpringCGLIB$$0.searchByQualification()
at com.flotomate.service.servicecatalog.ServiceCatalogServiceImpl.cloneFormRule(ServiceCatalogServiceImpl.java:881)
at com.flotomate.service.servicecatalog.ServiceCatalogServiceImpl.cloneServiceCatalog(ServiceCatalogServiceImpl.java:725)
at jdk.internal.reflect.GeneratedMethodAccessor679.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:569)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:360)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:196)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:380)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:89)
at com.flotomate.service.system.db.datasource.TransactionReadonlyAspect.proceed(TransactionReadonlyAspect.java:20)
at jdk.internal.reflect.GeneratedMethodAccessor152.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:569)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:649)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:631)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:71)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:173)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:728)
at com.flotomate.service.servicecatalog.ServiceCatalogServiceImpl$$SpringCGLIB$$0.cloneServiceCatalog()
at com.flotomate.service.servicecatalog.ServiceCatalogController.cloneServiceCatalog(ServiceCatalogController.java:172)
at jdk.internal.reflect.GeneratedMethodAccessor678.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:569)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:258)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:191)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:118)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:991)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:896)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1089)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:979)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:914)
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:590)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:885)
at org.springframework.test.web.servlet.TestDispatcherServlet.service(TestDispatcherServlet.java:72)
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:658)
at org.springframework.mock.web.MockFilterChain$ServletFilterProxy.doFilter(MockFilterChain.java:165)
at org.springframework.mock.web.MockFilterChain.doFilter(MockFilterChain.java:132)
at com.flotomate.service.base.filter.RequestThrottleFilter.doFilter(RequestThrottleFilter.java:89)
at org.springframework.test.web.servlet.setup.MockMvcFilterDecorator.doFilter(MockMvcFilterDecorator.java:162)
at org.springframework.mock.web.MockFilterChain.doFilter(MockFilterChain.java:132)
at com.flotomate.service.base.filter.ApiLoggerFilter.doFilter(ApiLoggerFilter.java:63)
at org.springframework.test.web.servlet.setup.MockMvcFilterDecorator.doFilter(MockMvcFilterDecorator.java:162)
at org.springframework.mock.web.MockFilterChain.doFilter(MockFilterChain.java:132)
at org.springframework.boot.actuate.web.exchanges.servlet.HttpExchangesFilter.doFilterInternal(HttpExchangesFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
at org.springframework.test.web.servlet.setup.MockMvcFilterDecorator.doFilter(MockMvcFilterDecorator.java:162)
at org.springframework.mock.web.MockFilterChain.doFilter(MockFilterChain.java:132)
at org.springframework.web.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:108)
at org.springframework.security.web.FilterChainProxy.lambda$doFilterInternal$3(FilterChainProxy.java:231)
at org.springframework.security.web.ObservationFilterChainDecorator$FilterObservation$SimpleFilterObservation.lambda$wrap$1(ObservationFilterChainDecorator.java:479)
at org.springframework.security.web.ObservationFilterChainDecorator$AroundFilterObservation$SimpleAroundFilterObservation.lambda$wrap$1(ObservationFilterChainDecorator.java:340)
at org.springframework.security.web.ObservationFilterChainDecorator.lambda$wrapSecured$0(ObservationFilterChainDecorator.java:82)
at org.springframework.security.web.ObservationFilterChainDecorator$VirtualFilterChain.doFilter(ObservationFilterChainDecorator.java:128)
at org.springframework.security.web.access.intercept.AuthorizationFilter.doFilter(AuthorizationFilter.java:100)
at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.wrapFilter(ObservationFilterChainDecorator.java:240)
at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.doFilter(ObservationFilterChainDecorator.java:227)
at org.springframework.security.web.ObservationFilterChainDecorator$VirtualFilterChain.doFilter(ObservationFilterChainDecorator.java:137)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:126)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:120)
at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.wrapFilter(ObservationFilterChainDecorator.java:240)
at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.doFilter(ObservationFilterChainDecorator.java:227)
at org.springframework.security.web.ObservationFilterChainDecorator$VirtualFilterChain.doFilter(ObservationFilterChainDecorator.java:137)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:100)
at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.wrapFilter(ObservationFilterChainDecorator.java:240)
at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.doFilter(ObservationFilterChainDecorator.java:227)
at org.springframework.security.web.ObservationFilterChainDecorator$VirtualFilterChain.doFilter(ObservationFilterChainDecorator.java:137)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:179)
at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.wrapFilter(ObservationFilterChainDecorator.java:240)
at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.doFilter(ObservationFilterChainDecorator.java:227)
at org.springframework.security.web.ObservationFilterChainDecorator$VirtualFilterChain.doFilter(ObservationFilterChainDecorator.java:137)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.wrapFilter(ObservationFilterChainDecorator.java:240)
at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.doFilter(ObservationFilterChainDecorator.java:227)
at org.springframework.security.web.ObservationFilterChainDecorator$VirtualFilterChain.doFilter(ObservationFilterChainDecorator.java:137)
at org.springframework.security.oauth2.server.resource.web.authentication.BearerTokenAuthenticationFilter.doFilterInternal(BearerTokenAuthenticationFilter.java:145)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.wrapFilter(ObservationFilterChainDecorator.java:240)
at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.doFilter(ObservationFilterChainDecorator.java:227)
at org.springframework.security.web.ObservationFilterChainDecorator$VirtualFilterChain.doFilter(ObservationFilterChainDecorator.java:137)
at com.flotomate.service.system.security.filter.ApiKeyAuthenticationFilter.doFilter(ApiKeyAuthenticationFilter.java:56)
at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.wrapFilter(ObservationFilterChainDecorator.java:240)
at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.doFilter(ObservationFilterChainDecorator.java:227)
at org.springframework.security.web.ObservationFilterChainDecorator$VirtualFilterChain.doFilter(ObservationFilterChainDecorator.java:137)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:107)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:93)
at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.wrapFilter(ObservationFilterChainDecorator.java:240)
at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.doFilter(ObservationFilterChainDecorator.java:227)
at org.springframework.security.web.ObservationFilterChainDecorator$VirtualFilterChain.doFilter(ObservationFilterChainDecorator.java:137)
at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:90)
at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:75)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.wrapFilter(ObservationFilterChainDecorator.java:240)
at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.doFilter(ObservationFilterChainDecorator.java:227)
at org.springframework.security.web.ObservationFilterChainDecorator$VirtualFilterChain.doFilter(ObservationFilterChainDecorator.java:137)
at org.springframework.security.web.context.SecurityContextHolderFilter.doFilter(SecurityContextHolderFilter.java:82)
at org.springframework.security.web.context.SecurityContextHolderFilter.doFilter(SecurityContextHolderFilter.java:69)
at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.wrapFilter(ObservationFilterChainDecorator.java:240)
at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.doFilter(ObservationFilterChainDecorator.java:227)
at org.springframework.security.web.ObservationFilterChainDecorator$VirtualFilterChain.doFilter(ObservationFilterChainDecorator.java:137)
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:62)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.wrapFilter(ObservationFilterChainDecorator.java:240)
at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.doFilter(ObservationFilterChainDecorator.java:227)
at org.springframework.security.web.ObservationFilterChainDecorator$VirtualFilterChain.doFilter(ObservationFilterChainDecorator.java:137)
at org.springframework.security.web.session.DisableEncodeUrlFilter.doFilterInternal(DisableEncodeUrlFilter.java:42)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.wrapFilter(ObservationFilterChainDecorator.java:240)
at org.springframework.security.web.ObservationFilterChainDecorator$AroundFilterObservation$SimpleAroundFilterObservation.lambda$wrap$0(ObservationFilterChainDecorator.java:323)
at org.springframework.security.web.ObservationFilterChainDecorator$ObservationFilter.doFilter(ObservationFilterChainDecorator.java:224)
at org.springframework.security.web.ObservationFilterChainDecorator$VirtualFilterChain.doFilter(ObservationFilterChainDecorator.java:137)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:233)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:191)
at org.springframework.web.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:113)
at org.springframework.web.servlet.handler.HandlerMappingIntrospector.lambda$createCacheFilter$4(HandlerMappingIntrospector.java:267)
at org.springframework.web.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:113)
at org.springframework.web.filter.CompositeFilter.doFilter(CompositeFilter.java:74)
at org.springframework.security.config.annotation.web.configuration.WebMvcSecurityConfiguration$CompositeFilterChainProxy.doFilter(WebMvcSecurityConfiguration.java:230)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:362)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:278)
at org.springframework.test.web.servlet.setup.MockMvcFilterDecorator.doFilter(MockMvcFilterDecorator.java:162)
at org.springframework.mock.web.MockFilterChain.doFilter(MockFilterChain.java:132)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
at org.springframework.test.web.servlet.setup.MockMvcFilterDecorator.doFilter(MockMvcFilterDecorator.java:162)
at org.springframework.mock.web.MockFilterChain.doFilter(MockFilterChain.java:132)
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
at org.springframework.test.web.servlet.setup.MockMvcFilterDecorator.doFilter(MockMvcFilterDecorator.java:162)
at org.springframework.mock.web.MockFilterChain.doFilter(MockFilterChain.java:132)
at com.flotomate.service.system.webfilter.PreAuthenticationValidationFilter.doFilter(PreAuthenticationValidationFilter.java:63)
at org.springframework.test.web.servlet.setup.MockMvcFilterDecorator.doFilter(MockMvcFilterDecorator.java:162)
at org.springframework.mock.web.MockFilterChain.doFilter(MockFilterChain.java:132)
at com.flotomate.service.system.webfilter.TenantIdentifyFilter.doFilter(TenantIdentifyFilter.java:164)
at org.springframework.test.web.servlet.setup.MockMvcFilterDecorator.doFilter(MockMvcFilterDecorator.java:162)
at org.springframework.mock.web.MockFilterChain.doFilter(MockFilterChain.java:132)
at org.springframework.web.filter.ServerHttpObservationFilter.doFilterInternal(ServerHttpObservationFilter.java:110)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
at org.springframework.test.web.servlet.setup.MockMvcFilterDecorator.doFilter(MockMvcFilterDecorator.java:162)
at org.springframework.mock.web.MockFilterChain.doFilter(MockFilterChain.java:132)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
at org.springframework.test.web.servlet.setup.MockMvcFilterDecorator.doFilter(MockMvcFilterDecorator.java:162)
at org.springframework.mock.web.MockFilterChain.doFilter(MockFilterChain.java:132)
at com.flotomate.service.system.security.ratelimiter.config.RateLimitFilter.doFilter(RateLimitFilter.java:85)
at org.springframework.test.web.servlet.setup.MockMvcFilterDecorator.doFilter(MockMvcFilterDecorator.java:162)
at org.springframework.mock.web.MockFilterChain.doFilter(MockFilterChain.java:132)
at com.flotomate.service.base.filter.SimpleCORSFilter.doFilter(SimpleCORSFilter.java:31)
at org.springframework.test.web.servlet.setup.MockMvcFilterDecorator.doFilter(MockMvcFilterDecorator.java:162)
at org.springframework.mock.web.MockFilterChain.doFilter(MockFilterChain.java:132)
at org.springframework.test.web.servlet.MockMvc.perform(MockMvc.java:201)
at com.flotomate.boot.CommonTest.post(CommonTest.java:814)
at com.flotomate.boot.CommonTest.post(CommonTest.java:738)
at com.flotomate.boot.servicecatalog.ServiceCatalogCloneTest.cloneServiceCatalog(ServiceCatalogCloneTest.java:1108)
at com.flotomate.boot.servicecatalog.ServiceCatalogCloneTest$WorkflowCloneTest.createWorkflowAndVerifyQualification(ServiceCatalogCloneTest.java:1729)
at jdk.internal.reflect.GeneratedMethodAccessor873.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:569)
at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:787)
at org.junit.platform.commons.support.ReflectionSupport.invokeMethod(ReflectionSupport.java:478)
at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
Caused by: java.lang.AssertionError
at org.hibernate.collection.spi.PersistentList.injectLoadedState(PersistentList.java:132)
at org.hibernate.sql.results.internal.LoadingCollectionEntryImpl.finishLoading(LoadingCollectionEntryImpl.java:78)
at org.hibernate.sql.results.jdbc.internal.JdbcValuesSourceProcessingStateStandardImpl.finishLoadingCollections(JdbcValuesSourceProcessingStateStandardImpl.java:171)
at org.hibernate.sql.results.jdbc.internal.JdbcValuesSourceProcessingStateStandardImpl.finishUp(JdbcValuesSourceProcessingStateStandardImpl.java:142)
at org.hibernate.sql.results.spi.ListResultsConsumer.consume(ListResultsConsumer.java:205)
at org.hibernate.sql.results.spi.ListResultsConsumer.consume(ListResultsConsumer.java:35)
at org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl.doExecuteQuery(JdbcSelectExecutorStandardImpl.java:224)
at org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl.executeQuery(JdbcSelectExecutorStandardImpl.java:102)
at org.hibernate.sql.exec.spi.JdbcSelectExecutor.executeQuery(JdbcSelectExecutor.java:91)
at org.hibernate.sql.exec.spi.JdbcSelectExecutor.list(JdbcSelectExecutor.java:165)
at org.hibernate.sql.exec.spi.JdbcSelectExecutor.list(JdbcSelectExecutor.java:142)
at org.hibernate.sql.exec.spi.JdbcSelectExecutor.list(JdbcSelectExecutor.java:132)
at org.hibernate.loader.ast.internal.CollectionBatchLoaderArrayParam.initializeKeys(CollectionBatchLoaderArrayParam.java:204)
at org.hibernate.loader.ast.internal.AbstractCollectionBatchLoader.load(AbstractCollectionBatchLoader.java:94)
at org.hibernate.loader.ast.internal.CollectionBatchLoaderArrayParam.load(CollectionBatchLoaderArrayParam.java:118)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:748)
at org.hibernate.event.internal.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:69)
at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:127)
at org.hibernate.internal.SessionImpl.initializeCollection(SessionImpl.java:1724)
at org.hibernate.collection.spi.AbstractPersistentCollection.lambda$initialize$3(AbstractPersistentCollection.java:616)
at org.hibernate.collection.spi.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:265)
at org.hibernate.collection.spi.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:614)
at org.hibernate.collection.spi.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:817)
at org.hibernate.engine.internal.StatefulPersistenceContext.initializeNonLazyCollections(StatefulPersistenceContext.java:1169)
at org.hibernate.engine.internal.StatefulPersistenceContext.initializeNonLazyCollections(StatefulPersistenceContext.java:1155)
at org.hibernate.sql.results.spi.ListResultsConsumer.consume(ListResultsConsumer.java:224)
at org.hibernate.sql.results.spi.ListResultsConsumer.consume(ListResultsConsumer.java:35)
at org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl.doExecuteQuery(JdbcSelectExecutorStandardImpl.java:224)
at org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl.executeQuery(JdbcSelectExecutorStandardImpl.java:102)
at org.hibernate.sql.exec.spi.JdbcSelectExecutor.executeQuery(JdbcSelectExecutor.java:91)
at org.hibernate.sql.exec.spi.JdbcSelectExecutor.list(JdbcSelectExecutor.java:165)
at org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan.lambda$new$1(ConcreteSqmSelectQueryPlan.java:149)
at org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan.withCacheableSqmInterpretation(ConcreteSqmSelectQueryPlan.java:439)
at org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan.performList(ConcreteSqmSelectQueryPlan.java:359)
at org.hibernate.query.sqm.internal.QuerySqmImpl.doList(QuerySqmImpl.java:380)
at org.hibernate.query.spi.AbstractSelectionQuery.list(AbstractSelectionQuery.java:143)
at org.hibernate.query.Query.getResultList(Query.java:120)
at com.flotomate.service.base.repository.AbstractFlotoBaseRepositoryImpl.getResultSet(AbstractFlotoBaseRepositoryImpl.java:96)
at com.flotomate.service.base.repository.FlotoEntityRepositoryImpl.getByQualFromCache(FlotoEntityRepositoryImpl.java:193)
at com.flotomate.service.base.repository.FlotoEntityRepositoryImpl.getAllByQual(FlotoEntityRepositoryImpl.java:150)
at jdk.internal.reflect.GeneratedMethodAccessor179.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:569)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:360)
at org.springframework.data.repository.core.support.RepositoryMethodInvoker$RepositoryFragmentMethodInvoker.lambda$new$0(RepositoryMethodInvoker.java:277)
… 335 more

I am using version 6.6.27Final . I have also tried with version 6.6.29Final.
Below is my entity Structure for your reference.

@Entity
@IgnoreNameAttribute
@UseCache(fullCache = true)
public class FooBar extends BaseClass{

    @JdbcTypeCode(SqlTypes.JSON)
    @Column(columnDefinition = "jsonb")
    private FooA fooA;

    private boolean fooB;

    @OneToMany(targetEntity = TargetClass.class, cascade = CascadeType.ALL, fetch = FetchType.EAGER, orphanRemoval = true)
    private Set<TargetClass> actions;
}

TargetClass:

@Entity
public class FormRuleAction extens BaseClass {
    
    @ElementCollection(targetClass = String.class, fetch = FetchType.EAGER)
    private Set<String> dbKeys;

    private String fieldKey;

    @OneToOne(fetch = FetchType.EAGER, orphanRemoval = true, cascade = CascadeType.ALL, targetEntity = TargetClassB.class)
    private TargetClassB value;
}

TargetClassB:

@Entity
@DynamicUpdate
public class TargetClassB extends BaseClass {
    @OneToOne(
        cascade = CascadeType.ALL,
        orphanRemoval = true,
        fetch = FetchType.EAGER,
        targetEntity = AttachmentEntity.class
    )
    private AttachmentEntity singleAttachment;

    @OneToOne(
        cascade = CascadeType.ALL,
        orphanRemoval = true,
        fetch = FetchType.EAGER,
        targetEntity = EnumEntity.class
    )
    private EnumEntity singleEnum;

    @OneToMany(
        cascade = CascadeType.ALL,
        orphanRemoval = true,
        fetch = FetchType.EAGER,
        targetEntity = AttachmentEntity.class
    )
    private List<AttachmentEntity> attachmentList;

    @ElementCollection(fetch = FetchType.EAGER, targetClass = Double.class)
    @OrderColumn
    private List<Double> doubleList;

    @OneToMany(
        cascade = CascadeType.ALL,
        orphanRemoval = true,
        fetch = FetchType.EAGER,
        targetEntity = EnumEntity.class
    )
    private Set<EnumEntity> enumSet;

    @ElementCollection(fetch = FetchType.EAGER, targetClass = Integer.class)
    @OrderColumn
    private List<Integer> integerList;

    @ElementCollection(fetch = FetchType.EAGER, targetClass = Long.class)
    @OrderColumn
    private List<Long> longList;

    @ElementCollection(fetch = FetchType.EAGER, targetClass = String.class)
    @OrderColumn
    private List<String> stringList;

    // getters/setters ...
}

Issue is Occurring when i am querying in DB to get FooBar entity.

Can you Please help me with the issue I am facing. Is there any problem in my entity design or it is hibernate issue, if yes then how to avoid it.

Your problem has absolutely nothing to do with what was asked here. Please create a new topic if you have a question. Posting unrelated stuff to an existing topic is not helpful.

Ok, I have added problem as new topic: java.lang.AssertionError: in RepositoryMethodInvoker

Thanks for reply!
We have bumped the version to 6.6.29.Final and will observe the CI.
But the problem still persists:

2025-09-29T10:18:25.0909470Z java.lang.AssertionError: null
2025-09-29T10:18:25.0911276Z 	at org.hibernate.sql.results.graph.entity.internal.EntityInitializerImpl.resolveEntityInstance1(EntityInitializerImpl.java:1118) ~[hibernate-core-6.6.29.Final.jar:6.6.29.Final]
2025-09-29T10:18:25.0914090Z 	at org.hibernate.sql.results.graph.entity.internal.EntityInitializerImpl.resolveInstance(EntityInitializerImpl.java:1032) ~[hibernate-core-6.6.29.Final.jar:6.6.29.Final]

Are you using bytecode enhancement?

  • there is no enhancement as far as I know, we for sure do not have enhancement maven plugin in our xml’s

Before the error, are there other logs that show data fetching from JDBC succeeds?

  • I do not quite understand what you mean. We use connection pooling so for sure there are no broken connections. Regarding the current connection (bound to transaction), the findAll is the first call in transaction.

Can you share the entity model and exact query please?

  • I do not want to provide here our code directly, need some time to maybe clean the names etc. But I can answer other questions which might push conversation going :wink:

If Account has an association to another Account which you are left join fetching, that might be an indicator about what is going on

  • yes! a2cp has backwards reference to the Account !

Or maybe the first row contains account 1 and the second row refers to this account 1 through an association

  • Also Yes! “ima” is actually of type Account (my bad, inserted there X6) but it is different account. But this “ima” account and “current” account will for sure be fetched in the same query, as we are doing findAll()

The queries:

Summary

The exact query (or queries):

SELECT DISTINCT a1_0.id,
                acp1_0.account,
                acp1_0.cauliflower_pool,
                acp1_0.type,
                a1_0.account_class,
                a1_0.account_type_id,
                a1_0.alternative_name,
                a1_0.balances_preferred_source_id,
                a1_0.balances_preferred_source_type,
                a1_0.balancing_type,
                bb1_0.id,
                b1_0.id,
                b1_0.bic,
                b1_0.business_id,
                b1_0.city,
                b1_0.country,
                b1_0.creation_time,
                b1_0.last_update_time,
                b1_0.NAME,
                b1_0.paybird_config,
                b1_0.postal_code,
                b1_0.street,
                bb1_0.bic,
                bb1_0.business_id,
                bb1_0.city,
                bb1_0.country,
                bb1_0.creation_time,
                hc1_0.barron_branch_id,
                hc1_1.id,
                hc1_1.creation_time,
                hc1_1.description,
                hc1_1.last_update_time,
                hc1_1.NAME,
                bb1_0.last_update_time,
                bb1_0.NAME,
                bb1_0.paybird_config,
                bb1_0.postal_code,
                bb1_0.street,
                bb1_0.time_zone,
                a1_0.business_id,
                a1_0.closing_date,
                a1_0.creation_time,
                a1_0.currency_id,
                c1_0.id,
                c1_0.creation_time,
                c1_0.last_message,
                c1_0.last_update_time,
                c1_0.NAME,
                c1_0.PRECISION,
                c1_0.status,
                c1_0.system_managed,
                a1_0.general_ledger_number,
                ima1_0.id,
                ima1_0.account_class,
                ima1_0.account_type_id,
                ima1_0.alternative_name,
                ima1_0.balances_preferred_source_id,
                ima1_0.balances_preferred_source_type,
                ima1_0.balancing_type,
                ima1_0.barron_branch_id,
                ima1_0.business_id,
                ima1_0.closing_date,
                ima1_0.creation_time,
                ima1_0.currency_id,
                ima1_0.general_ledger_number,
                ima1_0.ihb_mirroring_account_id,
                ima1_0.last_import_timestamp,
                ima1_0.last_update_time,
                ima1_0.legal_holder_id,
                ima1_0.min_funding_amount,
                ima1_0.min_sweeping_amount,
                ima1_0.NAME,
                ima1_0.opening_date,
                ima1_0.operational_holder_id,
                ima1_0.paybird_config,
                ima1_0.period_lock_end_date,
                ima1_0.target_balance,
                ima1_0.transactions_preferred_source_id,
                a1_0.last_import_timestamp,
                a1_0.last_update_time,
                lh1_0.id,
                lh1_0.alternative_name,
                lh1_0.business_id,
                lh1_0.closing_date,
                lh1_0.code,
                lh1_0.creation_time,
                lh1_0.currency_id,
                lh1_0.entity_type_id,
                lh1_0.last_update_time,
                lh1_0.NAME,
                lh1_0.opening_date,
                lh1_0.paybird_config,
                a1_0.min_funding_amount,
                a1_0.min_sweeping_amount,
                a1_0.NAME,
                a1_0.opening_date,
                a1_0.operational_holder_id,
                oh1_0.id,
                oh1_0.alternative_name,
                oh1_0.business_id,
                oh1_0.closing_date,
                oh1_0.code,
                oh1_0.creation_time,
                oh1_0.currency_id,
                oh1_0.entity_type_id,
                oh1_0.last_update_time,
                oh1_0.NAME,
                oh1_0.opening_date,
                oh1_0.paybird_config,
                a1_0.paybird_config,
                a1_0.period_lock_end_date,
                a1_0.target_balance,
                a1_0.transactions_preferred_source_id
FROM   account a1_0
       LEFT JOIN barron_branch bb1_0
              ON bb1_0.id = a1_0.barron_branch_id
       LEFT JOIN barron b1_0
              ON b1_0.id = bb1_0.bank_id
       LEFT JOIN barron_branch_holiday_calendar hc1_0
              ON bb1_0.id = hc1_0.barron_branch_id
       LEFT JOIN holiday_calendar hc1_1
              ON hc1_1.id = hc1_0.holiday_calendars_id
       LEFT JOIN account_cauliflower_pool acp1_0
              ON a1_0.id = acp1_0.account
       LEFT JOIN currency c1_0
              ON c1_0.id = a1_0.currency_id
       LEFT JOIN account ima1_0
              ON ima1_0.id = a1_0.ihb_mirroring_account_id
       LEFT JOIN entity oh1_0
              ON oh1_0.id = a1_0.operational_holder_id
       LEFT JOIN entity lh1_0
              ON lh1_0.id = a1_0.legal_holder_id

SELECT cp1_0.id,
       cp1_0.creation_time,
       c1_0.id,
       c1_0.creation_time,
       c1_0.last_message,
       c1_0.last_update_time,
       c1_0.NAME,
       c1_0.PRECISION,
       c1_0.status,
       c1_0.system_managed,
       cp1_0.last_update_time,
       cp1_0.NAME,
       cp1_0.status,
       cp1_0.type
FROM   cauliflower_pool cp1_0
       LEFT JOIN currency c1_0
              ON c1_0.id = cp1_0.currency_id
WHERE  cp1_0.id = ?

SELECT acp1_0.account,
       a1_0.id,
       a1_0.account_class,
       at1_0.id,
       at1_0.creation_time,
       at1_0.description,
       at1_0.item,
       at1_0.last_update_time,
       at1_0.level_id,
       l1_0.id,
       l1_0.creation_time,
       l1_0.last_update_time,
       l1_0.NAME,
       l1_0.order_nr,
       at1_0.order_nr,
       at1_0.parent_id,
       a1_0.alternative_name,
       bps1_0.id,
       bps1_0.configuration,
       bps1_0.creation_time,
       bps1_0.disabled,
       bps1_0.last_update_time,
       bps1_0.NAME,
       bps1_0.system_managed,
       bps1_0.type,
       f1_0.instance_id,
       f1_0.id,
       f1_0.creation_time,
       f1_0.feature_code,
       f1_0.last_refresh_time,
       f1_0.last_update_time,
       f1_0.nature,
       f1_0.status,
       a1_0.balances_preferred_source_type,
       a1_0.balancing_type,
       bb1_0.id,
       b1_0.id,
       b1_0.bic,
       b1_0.business_id,
       b1_0.city,
       b1_0.country,
       b1_0.creation_time,
       b1_0.last_update_time,
       b1_0.NAME,
       b1_0.paybird_config,
       b1_0.postal_code,
       b1_0.street,
       bb1_0.bic,
       bb1_0.business_id,
       bb1_0.city,
       bb1_0.country,
       bb1_0.creation_time,
       bb1_0.last_update_time,
       bb1_0.NAME,
       bb1_0.paybird_config,
       bb1_0.postal_code,
       bb1_0.street,
       bb1_0.time_zone,
       a1_0.business_id,
       a1_0.closing_date,
       a1_0.creation_time,
       a1_0.currency_id,
       c1_0.id,
       c1_0.creation_time,
       c1_0.last_message,
       c1_0.last_update_time,
       c1_0.NAME,
       c1_0.PRECISION,
       c1_0.status,
       c1_0.system_managed,
       a1_0.general_ledger_number,
       ima1_0.id,
       ima1_0.account_class,
       at2_0.id,
       at2_0.creation_time,
       at2_0.description,
       at2_0.item,
       at2_0.last_update_time,
       at2_0.level_id,
       l2_0.id,
       l2_0.creation_time,
       l2_0.last_update_time,
       l2_0.NAME,
       l2_0.order_nr,
       at2_0.order_nr,
       at2_0.parent_id,
       ima1_0.alternative_name,
       bps2_0.id,
       bps2_0.configuration,
       bps2_0.creation_time,
       bps2_0.disabled,
       bps2_0.last_update_time,
       bps2_0.NAME,
       bps2_0.system_managed,
       bps2_0.type,
       ima1_0.balances_preferred_source_type,
       ima1_0.balancing_type,
       bb2_0.id,
       b2_0.id,
       b2_0.bic,
       b2_0.business_id,
       b2_0.city,
       b2_0.country,
       b2_0.creation_time,
       b2_0.last_update_time,
       b2_0.NAME,
       b2_0.paybird_config,
       b2_0.postal_code,
       b2_0.street,
       bb2_0.bic,
       bb2_0.business_id,
       bb2_0.city,
       bb2_0.country,
       bb2_0.creation_time,
       bb2_0.last_update_time,
       bb2_0.NAME,
       bb2_0.paybird_config,
       bb2_0.postal_code,
       bb2_0.street,
       bb2_0.time_zone,
       ima1_0.business_id,
       ima1_0.closing_date,
       ima1_0.creation_time,
       ima1_0.currency_id,
       c2_0.id,
       c2_0.creation_time,
       c2_0.last_message,
       c2_0.last_update_time,
       c2_0.NAME,
       c2_0.PRECISION,
       c2_0.status,
       c2_0.system_managed,
       ima1_0.general_ledger_number,
       ima1_0.ihb_mirroring_account_id,
       ima1_0.last_import_timestamp,
       ima1_0.last_update_time,
       lh1_0.id,
       lh1_0.alternative_name,
       lh1_0.business_id,
       lh1_0.closing_date,
       lh1_0.code,
       lh1_0.creation_time,
       c3_0.id,
       c3_0.creation_time,
       c3_0.last_message,
       c3_0.last_update_time,
       c3_0.NAME,
       c3_0.PRECISION,
       c3_0.status,
       c3_0.system_managed,
       et1_0.id,
       et1_0.creation_time,
       et1_0.description,
       et1_0.item,
       et1_0.last_update_time,
       et1_0.level_id,
       l3_0.id,
       l3_0.creation_time,
       l3_0.last_update_time,
       l3_0.NAME,
       l3_0.order_nr,
       et1_0.order_nr,
       et1_0.parent_id,
       lh1_0.last_update_time,
       lh1_0.NAME,
       lh1_0.opening_date,
       lh1_0.paybird_config,
       ima1_0.min_funding_amount,
       ima1_0.min_sweeping_amount,
       ima1_0.NAME,
       ima1_0.opening_date,
       ima1_0.operational_holder_id,
       oh1_0.id,
       oh1_0.alternative_name,
       oh1_0.business_id,
       oh1_0.closing_date,
       oh1_0.code,
       oh1_0.creation_time,
       c4_0.id,
       c4_0.creation_time,
       c4_0.last_message,
       c4_0.last_update_time,
       c4_0.NAME,
       c4_0.PRECISION,
       c4_0.status,
       c4_0.system_managed,
       et2_0.id,
       et2_0.creation_time,
       et2_0.description,
       et2_0.item,
       et2_0.last_update_time,
       et2_0.level_id,
       l4_0.id,
       l4_0.creation_time,
       l4_0.last_update_time,
       l4_0.NAME,
       l4_0.order_nr,
       et2_0.order_nr,
       et2_0.parent_id,
       oh1_0.last_update_time,
       oh1_0.NAME,
       oh1_0.opening_date,
       oh1_0.paybird_config,
       ima1_0.paybird_config,
       ima1_0.period_lock_end_date,
       ima1_0.target_balance,
       tps1_0.id,
       tps1_0.configuration,
       tps1_0.creation_time,
       tps1_0.disabled,
       tps1_0.last_update_time,
       tps1_0.NAME,
       tps1_0.system_managed,
       tps1_0.type,
       a1_0.last_import_timestamp,
       a1_0.last_update_time,
       lh2_0.id,
       lh2_0.alternative_name,
       lh2_0.business_id,
       lh2_0.closing_date,
       lh2_0.code,
       lh2_0.creation_time,
       c5_0.id,
       c5_0.creation_time,
       c5_0.last_message,
       c5_0.last_update_time,
       c5_0.NAME,
       c5_0.PRECISION,
       c5_0.status,
       c5_0.system_managed,
       et3_0.id,
       et3_0.creation_time,
       et3_0.description,
       et3_0.item,
       et3_0.last_update_time,
       et3_0.level_id,
       l5_0.id,
       l5_0.creation_time,
       l5_0.last_update_time,
       l5_0.NAME,
       l5_0.order_nr,
       et3_0.order_nr,
       et3_0.parent_id,
       lh2_0.last_update_time,
       lh2_0.NAME,
       lh2_0.opening_date,
       lh2_0.paybird_config,
       a1_0.min_funding_amount,
       a1_0.min_sweeping_amount,
       a1_0.NAME,
       a1_0.opening_date,
       a1_0.operational_holder_id,
       oh2_0.id,
       oh2_0.alternative_name,
       oh2_0.business_id,
       oh2_0.closing_date,
       oh2_0.code,
       oh2_0.creation_time,
       c6_0.id,
       c6_0.creation_time,
       c6_0.last_message,
       c6_0.last_update_time,
       c6_0.NAME,
       c6_0.PRECISION,
       c6_0.status,
       c6_0.system_managed,
       et4_0.id,
       et4_0.creation_time,
       et4_0.description,
       et4_0.item,
       et4_0.last_update_time,
       et4_0.level_id,
       l6_0.id,
       l6_0.creation_time,
       l6_0.last_update_time,
       l6_0.NAME,
       l6_0.order_nr,
       et4_0.order_nr,
       et4_0.parent_id,
       oh2_0.last_update_time,
       oh2_0.NAME,
       oh2_0.opening_date,
       oh2_0.paybird_config,
       a1_0.paybird_config,
       a1_0.period_lock_end_date,
       a1_0.target_balance,
       tps2_0.id,
       tps2_0.configuration,
       tps2_0.creation_time,
       tps2_0.disabled,
       tps2_0.last_update_time,
       tps2_0.NAME,
       tps2_0.system_managed,
       tps2_0.type,
       acp1_0.cauliflower_pool,
       cp1_0.id,
       cp1_0.creation_time,
       c7_0.id,
       c7_0.creation_time,
       c7_0.last_message,
       c7_0.last_update_time,
       c7_0.NAME,
       c7_0.PRECISION,
       c7_0.status,
       c7_0.system_managed,
       cp1_0.last_update_time,
       cp1_0.NAME,
       cp1_0.status,
       cp1_0.type,
       acp1_0.type
FROM   account_cauliflower_pool acp1_0
       JOIN account a1_0
         ON a1_0.id = acp1_0.account
       LEFT JOIN account_type at1_0
              ON at1_0.id = a1_0.account_type_id
       LEFT JOIN account_type_level l1_0
              ON l1_0.id = at1_0.level_id
       LEFT JOIN connector_instance bps1_0
              ON bps1_0.id = a1_0.balances_preferred_source_id
                 AND bps1_0.deleted = false
       LEFT JOIN connector_instance_feature f1_0
              ON bps1_0.id = f1_0.instance_id
                 AND f1_0.deleted = false
       LEFT JOIN barron_branch bb1_0
              ON bb1_0.id = a1_0.barron_branch_id
       LEFT JOIN barron b1_0
              ON b1_0.id = bb1_0.bank_id
       JOIN currency c1_0
         ON c1_0.id = a1_0.currency_id
       LEFT JOIN account ima1_0
              ON ima1_0.id = a1_0.ihb_mirroring_account_id
       LEFT JOIN account_type at2_0
              ON at2_0.id = ima1_0.account_type_id
       LEFT JOIN account_type_level l2_0
              ON l2_0.id = at2_0.level_id
       LEFT JOIN connector_instance bps2_0
              ON bps2_0.id = ima1_0.balances_preferred_source_id
                 AND bps2_0.deleted = false
       LEFT JOIN barron_branch bb2_0
              ON bb2_0.id = ima1_0.barron_branch_id
       LEFT JOIN barron b2_0
              ON b2_0.id = bb2_0.bank_id
       LEFT JOIN currency c2_0
              ON c2_0.id = ima1_0.currency_id
       LEFT JOIN entity lh1_0
              ON lh1_0.id = ima1_0.legal_holder_id
       LEFT JOIN currency c3_0
              ON c3_0.id = lh1_0.currency_id
       LEFT JOIN entity_type et1_0
              ON et1_0.id = lh1_0.entity_type_id
       LEFT JOIN entity_type_level l3_0
              ON l3_0.id = et1_0.level_id
       LEFT JOIN entity oh1_0
              ON oh1_0.id = ima1_0.operational_holder_id
       LEFT JOIN currency c4_0
              ON c4_0.id = oh1_0.currency_id
       LEFT JOIN entity_type et2_0
              ON et2_0.id = oh1_0.entity_type_id
       LEFT JOIN entity_type_level l4_0
              ON l4_0.id = et2_0.level_id
       LEFT JOIN connector_instance tps1_0
              ON tps1_0.id = ima1_0.transactions_preferred_source_id
                 AND tps1_0.deleted = false
       LEFT JOIN entity lh2_0
              ON lh2_0.id = a1_0.legal_holder_id
       LEFT JOIN currency c5_0
              ON c5_0.id = lh2_0.currency_id
       LEFT JOIN entity_type et3_0
              ON et3_0.id = lh2_0.entity_type_id
       LEFT JOIN entity_type_level l5_0
              ON l5_0.id = et3_0.level_id
       JOIN entity oh2_0
         ON oh2_0.id = a1_0.operational_holder_id
       LEFT JOIN currency c6_0
              ON c6_0.id = oh2_0.currency_id
       LEFT JOIN entity_type et4_0
              ON et4_0.id = oh2_0.entity_type_id
       LEFT JOIN entity_type_level l6_0
              ON l6_0.id = et4_0.level_id
       LEFT JOIN connector_instance tps2_0
              ON tps2_0.id = a1_0.transactions_preferred_source_id
                 AND tps2_0.deleted = false
       JOIN cauliflower_pool cp1_0
         ON cp1_0.id = acp1_0.cauliflower_pool
       LEFT JOIN currency c7_0
              ON c7_0.id = cp1_0.currency_id
WHERE  acp1_0.account = ?

SELECT acp1_0.account,
       a1_0.id,
       a1_0.account_class,
       at1_0.id,
       at1_0.creation_time,
       at1_0.description,
       at1_0.item,
       at1_0.last_update_time,
       at1_0.level_id,
       l1_0.id,
       l1_0.creation_time,
       l1_0.last_update_time,
       l1_0.NAME,
       l1_0.order_nr,
       at1_0.order_nr,
       at1_0.parent_id,
       a1_0.alternative_name,
       bps1_0.id,
       bps1_0.configuration,
       bps1_0.creation_time,
       bps1_0.disabled,
       bps1_0.last_update_time,
       bps1_0.NAME,
       bps1_0.system_managed,
       bps1_0.type,
       f1_0.instance_id,
       f1_0.id,
       f1_0.creation_time,
       f1_0.feature_code,
       f1_0.last_refresh_time,
       f1_0.last_update_time,
       f1_0.nature,
       f1_0.status,
       a1_0.balances_preferred_source_type,
       a1_0.balancing_type,
       bb1_0.id,
       b1_0.id,
       b1_0.bic,
       b1_0.business_id,
       b1_0.city,
       b1_0.country,
       b1_0.creation_time,
       b1_0.last_update_time,
       b1_0.NAME,
       b1_0.paybird_config,
       b1_0.postal_code,
       b1_0.street,
       bb1_0.bic,
       bb1_0.business_id,
       bb1_0.city,
       bb1_0.country,
       bb1_0.creation_time,
       bb1_0.last_update_time,
       bb1_0.NAME,
       bb1_0.paybird_config,
       bb1_0.postal_code,
       bb1_0.street,
       bb1_0.time_zone,
       a1_0.business_id,
       a1_0.closing_date,
       a1_0.creation_time,
       a1_0.currency_id,
       c1_0.id,
       c1_0.creation_time,
       c1_0.last_message,
       c1_0.last_update_time,
       c1_0.NAME,
       c1_0.PRECISION,
       c1_0.status,
       c1_0.system_managed,
       a1_0.general_ledger_number,
       ima1_0.id,
       ima1_0.account_class,
       at2_0.id,
       at2_0.creation_time,
       at2_0.description,
       at2_0.item,
       at2_0.last_update_time,
       at2_0.level_id,
       l2_0.id,
       l2_0.creation_time,
       l2_0.last_update_time,
       l2_0.NAME,
       l2_0.order_nr,
       at2_0.order_nr,
       at2_0.parent_id,
       ima1_0.alternative_name,
       bps2_0.id,
       bps2_0.configuration,
       bps2_0.creation_time,
       bps2_0.disabled,
       bps2_0.last_update_time,
       bps2_0.NAME,
       bps2_0.system_managed,
       bps2_0.type,
       ima1_0.balances_preferred_source_type,
       ima1_0.balancing_type,
       bb2_0.id,
       b2_0.id,
       b2_0.bic,
       b2_0.business_id,
       b2_0.city,
       b2_0.country,
       b2_0.creation_time,
       b2_0.last_update_time,
       b2_0.NAME,
       b2_0.paybird_config,
       b2_0.postal_code,
       b2_0.street,
       bb2_0.bic,
       bb2_0.business_id,
       bb2_0.city,
       bb2_0.country,
       bb2_0.creation_time,
       bb2_0.last_update_time,
       bb2_0.NAME,
       bb2_0.paybird_config,
       bb2_0.postal_code,
       bb2_0.street,
       bb2_0.time_zone,
       ima1_0.business_id,
       ima1_0.closing_date,
       ima1_0.creation_time,
       ima1_0.currency_id,
       c2_0.id,
       c2_0.creation_time,
       c2_0.last_message,
       c2_0.last_update_time,
       c2_0.NAME,
       c2_0.PRECISION,
       c2_0.status,
       c2_0.system_managed,
       ima1_0.general_ledger_number,
       ima1_0.ihb_mirroring_account_id,
       ima1_0.last_import_timestamp,
       ima1_0.last_update_time,
       lh1_0.id,
       lh1_0.alternative_name,
       lh1_0.business_id,
       lh1_0.closing_date,
       lh1_0.code,
       lh1_0.creation_time,
       c3_0.id,
       c3_0.creation_time,
       c3_0.last_message,
       c3_0.last_update_time,
       c3_0.NAME,
       c3_0.PRECISION,
       c3_0.status,
       c3_0.system_managed,
       et1_0.id,
       et1_0.creation_time,
       et1_0.description,
       et1_0.item,
       et1_0.last_update_time,
       et1_0.level_id,
       l3_0.id,
       l3_0.creation_time,
       l3_0.last_update_time,
       l3_0.NAME,
       l3_0.order_nr,
       et1_0.order_nr,
       et1_0.parent_id,
       lh1_0.last_update_time,
       lh1_0.NAME,
       lh1_0.opening_date,
       lh1_0.paybird_config,
       ima1_0.min_funding_amount,
       ima1_0.min_sweeping_amount,
       ima1_0.NAME,
       ima1_0.opening_date,
       ima1_0.operational_holder_id,
       oh1_0.id,
       oh1_0.alternative_name,
       oh1_0.business_id,
       oh1_0.closing_date,
       oh1_0.code,
       oh1_0.creation_time,
       c4_0.id,
       c4_0.creation_time,
       c4_0.last_message,
       c4_0.last_update_time,
       c4_0.NAME,
       c4_0.PRECISION,
       c4_0.status,
       c4_0.system_managed,
       et2_0.id,
       et2_0.creation_time,
       et2_0.description,
       et2_0.item,
       et2_0.last_update_time,
       et2_0.level_id,
       l4_0.id,
       l4_0.creation_time,
       l4_0.last_update_time,
       l4_0.NAME,
       l4_0.order_nr,
       et2_0.order_nr,
       et2_0.parent_id,
       oh1_0.last_update_time,
       oh1_0.NAME,
       oh1_0.opening_date,
       oh1_0.paybird_config,
       ima1_0.paybird_config,
       ima1_0.period_lock_end_date,
       ima1_0.target_balance,
       tps1_0.id,
       tps1_0.configuration,
       tps1_0.creation_time,
       tps1_0.disabled,
       tps1_0.last_update_time,
       tps1_0.NAME,
       tps1_0.system_managed,
       tps1_0.type,
       a1_0.last_import_timestamp,
       a1_0.last_update_time,
       lh2_0.id,
       lh2_0.alternative_name,
       lh2_0.business_id,
       lh2_0.closing_date,
       lh2_0.code,
       lh2_0.creation_time,
       c5_0.id,
       c5_0.creation_time,
       c5_0.last_message,
       c5_0.last_update_time,
       c5_0.NAME,
       c5_0.PRECISION,
       c5_0.status,
       c5_0.system_managed,
       et3_0.id,
       et3_0.creation_time,
       et3_0.description,
       et3_0.item,
       et3_0.last_update_time,
       et3_0.level_id,
       l5_0.id,
       l5_0.creation_time,
       l5_0.last_update_time,
       l5_0.NAME,
       l5_0.order_nr,
       et3_0.order_nr,
       et3_0.parent_id,
       lh2_0.last_update_time,
       lh2_0.NAME,
       lh2_0.opening_date,
       lh2_0.paybird_config,
       a1_0.min_funding_amount,
       a1_0.min_sweeping_amount,
       a1_0.NAME,
       a1_0.opening_date,
       a1_0.operational_holder_id,
       oh2_0.id,
       oh2_0.alternative_name,
       oh2_0.business_id,
       oh2_0.closing_date,
       oh2_0.code,
       oh2_0.creation_time,
       c6_0.id,
       c6_0.creation_time,
       c6_0.last_message,
       c6_0.last_update_time,
       c6_0.NAME,
       c6_0.PRECISION,
       c6_0.status,
       c6_0.system_managed,
       et4_0.id,
       et4_0.creation_time,
       et4_0.description,
       et4_0.item,
       et4_0.last_update_time,
       et4_0.level_id,
       l6_0.id,
       l6_0.creation_time,
       l6_0.last_update_time,
       l6_0.NAME,
       l6_0.order_nr,
       et4_0.order_nr,
       et4_0.parent_id,
       oh2_0.last_update_time,
       oh2_0.NAME,
       oh2_0.opening_date,
       oh2_0.paybird_config,
       a1_0.paybird_config,
       a1_0.period_lock_end_date,
       a1_0.target_balance,
       tps2_0.id,
       tps2_0.configuration,
       tps2_0.creation_time,
       tps2_0.disabled,
       tps2_0.last_update_time,
       tps2_0.NAME,
       tps2_0.system_managed,
       tps2_0.type,
       acp1_0.cauliflower_pool,
       cp1_0.id,
       cp1_0.creation_time,
       c7_0.id,
       c7_0.creation_time,
       c7_0.last_message,
       c7_0.last_update_time,
       c7_0.NAME,
       c7_0.PRECISION,
       c7_0.status,
       c7_0.system_managed,
       cp1_0.last_update_time,
       cp1_0.NAME,
       cp1_0.status,
       cp1_0.type,
       acp1_0.type
FROM   account_cauliflower_pool acp1_0
       JOIN account a1_0
         ON a1_0.id = acp1_0.account
       LEFT JOIN account_type at1_0
              ON at1_0.id = a1_0.account_type_id
       LEFT JOIN account_type_level l1_0
              ON l1_0.id = at1_0.level_id
       LEFT JOIN connector_instance bps1_0
              ON bps1_0.id = a1_0.balances_preferred_source_id
                 AND bps1_0.deleted = false
       LEFT JOIN connector_instance_feature f1_0
              ON bps1_0.id = f1_0.instance_id
                 AND f1_0.deleted = false
       LEFT JOIN barron_branch bb1_0
              ON bb1_0.id = a1_0.barron_branch_id
       LEFT JOIN barron b1_0
              ON b1_0.id = bb1_0.bank_id
       JOIN currency c1_0
         ON c1_0.id = a1_0.currency_id
       LEFT JOIN account ima1_0
              ON ima1_0.id = a1_0.ihb_mirroring_account_id
       LEFT JOIN account_type at2_0
              ON at2_0.id = ima1_0.account_type_id
       LEFT JOIN account_type_level l2_0
              ON l2_0.id = at2_0.level_id
       LEFT JOIN connector_instance bps2_0
              ON bps2_0.id = ima1_0.balances_preferred_source_id
                 AND bps2_0.deleted = false
       LEFT JOIN barron_branch bb2_0
              ON bb2_0.id = ima1_0.barron_branch_id
       LEFT JOIN barron b2_0
              ON b2_0.id = bb2_0.bank_id
       LEFT JOIN currency c2_0
              ON c2_0.id = ima1_0.currency_id
       LEFT JOIN entity lh1_0
              ON lh1_0.id = ima1_0.legal_holder_id
       LEFT JOIN currency c3_0
              ON c3_0.id = lh1_0.currency_id
       LEFT JOIN entity_type et1_0
              ON et1_0.id = lh1_0.entity_type_id
       LEFT JOIN entity_type_level l3_0
              ON l3_0.id = et1_0.level_id
       LEFT JOIN entity oh1_0
              ON oh1_0.id = ima1_0.operational_holder_id
       LEFT JOIN currency c4_0
              ON c4_0.id = oh1_0.currency_id
       LEFT JOIN entity_type et2_0
              ON et2_0.id = oh1_0.entity_type_id
       LEFT JOIN entity_type_level l4_0
              ON l4_0.id = et2_0.level_id
       LEFT JOIN connector_instance tps1_0
              ON tps1_0.id = ima1_0.transactions_preferred_source_id
                 AND tps1_0.deleted = false
       LEFT JOIN entity lh2_0
              ON lh2_0.id = a1_0.legal_holder_id
       LEFT JOIN currency c5_0
              ON c5_0.id = lh2_0.currency_id
       LEFT JOIN entity_type et3_0
              ON et3_0.id = lh2_0.entity_type_id
       LEFT JOIN entity_type_level l5_0
              ON l5_0.id = et3_0.level_id
       JOIN entity oh2_0
         ON oh2_0.id = a1_0.operational_holder_id
       LEFT JOIN currency c6_0
              ON c6_0.id = oh2_0.currency_id
       LEFT JOIN entity_type et4_0
              ON et4_0.id = oh2_0.entity_type_id
       LEFT JOIN entity_type_level l6_0
              ON l6_0.id = et4_0.level_id
       LEFT JOIN connector_instance tps2_0
              ON tps2_0.id = a1_0.transactions_preferred_source_id
                 AND tps2_0.deleted = false
       JOIN cauliflower_pool cp1_0
         ON cp1_0.id = acp1_0.cauliflower_pool
       LEFT JOIN currency c7_0
              ON c7_0.id = cp1_0.currency_id
WHERE  acp1_0.account = ?

SELECT bb1_0.id,
       b1_0.id,
       b1_0.bic,
       b1_0.business_id,
       b1_0.city,
       b1_0.country,
       b1_0.creation_time,
       b1_0.last_update_time,
       b1_0.NAME,
       b1_0.paybird_config,
       b1_0.postal_code,
       b1_0.street,
       bb1_0.bic,
       bb1_0.business_id,
       bb1_0.city,
       bb1_0.country,
       bb1_0.creation_time,
       bb1_0.last_update_time,
       bb1_0.NAME,
       bb1_0.paybird_config,
       bb1_0.postal_code,
       bb1_0.street,
       bb1_0.time_zone
FROM   barron_branch bb1_0
       LEFT JOIN barron b1_0
              ON b1_0.id = bb1_0.bank_id
WHERE  bb1_0.id = ?

SELECT e1_0.id,
       e1_0.alternative_name,
       e1_0.business_id,
       e1_0.closing_date,
       e1_0.code,
       e1_0.creation_time,
       c1_0.id,
       c1_0.creation_time,
       c1_0.last_message,
       c1_0.last_update_time,
       c1_0.NAME,
       c1_0.PRECISION,
       c1_0.status,
       c1_0.system_managed,
       et1_0.id,
       et1_0.creation_time,
       et1_0.description,
       et1_0.item,
       et1_0.last_update_time,
       et1_0.level_id,
       l1_0.id,
       l1_0.creation_time,
       l1_0.last_update_time,
       l1_0.NAME,
       l1_0.order_nr,
       et1_0.order_nr,
       et1_0.parent_id,
       e1_0.last_update_time,
       e1_0.NAME,
       e1_0.opening_date,
       e1_0.paybird_config
FROM   entity e1_0
       LEFT JOIN currency c1_0
              ON c1_0.id = e1_0.currency_id
       LEFT JOIN entity_type et1_0
              ON et1_0.id = e1_0.entity_type_id
       LEFT JOIN entity_type_level l1_0
              ON l1_0.id = et1_0.level_id
WHERE  e1_0.id = ? 

Basically , cauliflower_pool has back reference to Account.
And ihb account is reference to other row from returned accounts.

EDIT:
We actually might be able to prepare some reproduction example, will post it later if we succeed

1 Like

Before the error, are there other logs that show data fetching from JDBC succeeds?

If you enable org.hibernate.orm.jdbc.extract logging, you will see the values that are read from a JDBC ResultSet in the logs. Knowing whether the first few rows of the problematic query are read might help understand the problem

We actually might be able to prepare some reproduction example, will post it later if we succeed

Sounds like my questions gave you the right hints already. Looking forward to your reproducer.

I can get the logs of (org.hibernate.orm.jdbc.extract) but I do not have much idea how to read them.
Also, is the graph building by hibernate safe for concurrent modifications while reading?
What I am observign is that ssertion error is happeing on separate thread, where we iterate over all account anytime something changes in database.
So in main thread we setup our associations, one-by-one without transaction.

When hibernate builds the graph it issues several queries. Could it be that assosciation appering in between those queries makes the assert assumption wrong?

The error is happeing spradicaly, it will be a major effort to distill the correct setup for exact reproduction. I was trying to force it by making paralle loads more often, but couldnt really find a pettern.

Would you make a use of those org.hibernate.orm.jdbc.extract logs?
findAll() is called without encompassing transaciton and hibernate session, so everything in hibernate context should be fresh. How is it even possible that we get different initializers?

While I cannot debug the problem properly as reproduction is very random and requires several runs, I was able to compile hibernate-core with some print statements.
Here is what I get so far, when the error occurs:

Other initializer class: org.hibernate.sql.results.graph.entity.internal.EntitySelectFetchInitializer
Other initializer: x.Account(a).ihbMirroringAccount(ima).bankBranch
This initializer: x.Account(a).bankBranch(bb)

That means it is the “BankBranch” entity. And it is loaded by ihbMirroringAccount by one initializer, and then by “account” by another initializer. Both accounts are the same, but the asossiaciton is not added in single transaction.

Also, is the graph building by hibernate safe for concurrent modifications while reading?

It should be, yes.

When hibernate builds the graph it issues several queries. Could it be that assosciation appering in between those queries makes the assert assumption wrong?

This might very well be.

It’s great that you can dig deeper into this now with a custom build. I understand that it might be hard to debug this problem, given that it doesn’t happen all the time, but I need you to provide me the relevant entity class definitions so I can think through what might be happening.

So what I think might be happening is the following:

  • The EntitySelectFetchInitializer#resolveInstance method for x.Account(a).ihbMirroringAccount(ima).bankBranch is called
  • This in turn will call Session#internalLoad, but for some reason that returns null (maybe the entity was removed?)
  • I assume the BankBranch association in the ihbMirroringAccount entity has @NotFound(IGNORE) annotated or you have a tenant filter that excludes this referred entity from being fetched? Due to this, the entity will be set to null on the EntityHolder
  • When the EntityInitializerImpl#resolveInstance method runs for x.Account(a).bankBranch(bb), it will see this EntityHolder, but because the entity is null, it assumes that it will have to initialize the state of the entity, but then fails the assertion because the x.Account(a).ihbMirroringAccount(ima).bankBranch initializer already initialized this to null

If you can confirm this scenario, I should hopefully be able to construct a reproducer for this.

Hey, it was a while but finally I have soem more time to get back to it.
So we have remedied the problem by fetching the graph in repeatable_read isolation. This shows that indeed we are hitting some concurrency problems in Hibernate.

Unfortunately I was unable to create a reproductible example, but can give more details here.

@jakarta.persistence.Entity
@Table(name = “account”)
public class Account {

@OneToOne
private Account ihbMirroringAccount;

@ManyToOne
private BankBranch bankBranch;
}

@Entity
@Table(name = “bank_branch”)
public class BankBranch {

}

These are our entities.
We are doing fetchAll() and :

@Query(
select distinct a from Account a "

  • "left join fetch a.bankBranch bb "
  • "left join fetch a.ihbMirroringAccount ima " )

….
List findAll();

Just before we hit assertion error, inside EntityInitializerImpl.class I am performing a system.out log:

else {
if(data.entityHolder.getEntityInitializer() != this && data.entityHolder.getEntityInitializer() != null){
EntityInitializer<?> entityInitializer = data.entityHolder.getEntityInitializer();
System.out.println("Other initializer class: " + entityInitializer.getClass().getName());
System.out.println("Other initializer: " + entityInitializer.getNavigablePath().toString());
System.out.println("This initializer: " + this.getNavigablePath().toString());
}
assert data.entityHolder.getEntityInitializer() == this;

and the result is:

Other initializer class: org.hibernate.sql.results.graph.entity.internal.EntitySelectFetchInitializer
Other initializer: io.cashforce.ng.platformapi.data.masterdata.account.model.Account(a).ihbMirroringAccount(ima).bankBranch
This initializer: io.cashforce.ng.platformapi.data.masterdata.account.model.Account(a).bankBranch(bb)

How is the graph constructed?
As it is a test environment, we are filling database without much regard to transactionality. Basically we issue commands one after another, there is no transaction on top of them.

  1. Create mirrorAccount. (ma1)

  2. create mirrorAccount’s bankBranch (bb1)

  3. add bb1 to ma1

  4. create theAccount (ta1)

  5. add ma1 to ta1

    So I suppose that th problem we have is with point 5.
    io.cashforce.ng.platformapi.data.masterdata.account.model.Account(a).bankBranch(bb) may be missing bank branch, but io.cashforce.ng.platformapi.data.masterdata.account.model.Account(a).ihbMirroringAccount(ima).bankBranch already may have it (depending on order of fetch operations).

!! Due to the nature of our system, findAll() is not performed after all the data is written to db.
It may be called during points 1-5, because these are more like integration tests and other processes might call findAll() concurrently

Regards

How are you creating the database schema i.e. do your tables have foreign key constraints? Specifically, is there a FK constraint from account to bank_branch for the bank_branch_id column?
Also, do you potentially run other tests at the same time on that database that might delete data?