You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
org.springframework.dao.InvalidDataAccessApiUsageException: Unable to locate Attribute with the given name [user] on this ManagedType [java.lang.Object]
at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:371)
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:234)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:550)
at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:61)
Caused by: java.lang.IllegalArgumentException: Unable to locate Attribute with the given name [user] on this ManagedType [java.lang.Object]
at org.hibernate.metamodel.model.domain.AbstractManagedType.checkNotNull(AbstractManagedType.java:287)
at org.hibernate.metamodel.model.domain.AbstractManagedType.getAttribute(AbstractManagedType.java:160)
at org.hibernate.metamodel.model.domain.AbstractManagedType.getAttribute(AbstractManagedType.java:51)
at org.springframework.data.jpa.repository.query.QueryUtils.requiresOuterJoin(QueryUtils.java:836)
at org.springframework.data.jpa.repository.query.QueryUtils.toExpressionRecursively(QueryUtils.java:777)
at org.springframework.data.jpa.repository.query.QueryUtils.toExpressionRecursively(QueryUtils.java:796)
at org.springframework.data.jpa.repository.query.QueryUtils.toExpressionRecursively(QueryUtils.java:756)
at org.springframework.data.jpa.repository.query.QueryUtils.toExpressionRecursively(QueryUtils.java:752)
at org.springframework.data.jpa.repository.query.QueryUtils.toJpaOrder(QueryUtils.java:741)
at org.springframework.data.jpa.repository.query.QueryUtils.toOrders(QueryUtils.java:693)
at org.springframework.data.jpa.repository.support.SimpleJpaRepository.getQuery(SimpleJpaRepository.java:753)
at org.springframework.data.jpa.repository.support.SimpleJpaRepository.getQuery(SimpleJpaRepository.java:710)
at org.springframework.data.jpa.repository.support.SimpleJpaRepository.findAll(SimpleJpaRepository.java:447)
I think it's because the type "E entity" was transformed to Object after being compiled. I even tested TypedSort to see if it can access the generic field:
But seems like Spring can not create a proxy, I got this error:
org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class java.lang.Object: Common causes of this problem include using a final class or a non-visible class
at org.springframework.aop.framework.CglibAopProxy.buildProxy(CglibAopProxy.java:216)
at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:158)
at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:110)
at org.springframework.data.util.MethodInvocationRecorder.create(MethodInvocationRecorder.java:100)
at org.springframework.data.util.MethodInvocationRecorder$RecordingMethodInterceptor.registerInvocation(MethodInvocationRecorder.java:159)
at org.springframework.data.util.MethodInvocationRecorder$RecordingMethodInterceptor.invoke(MethodInvocationRecorder.java:150)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:702)
at com.ntuc.lhub.custom.common.data.entity.funding.FundingApproverActivityChangeLog$$SpringCGLIB$$0.getEntity(<generated>)
Caused by: org.springframework.cglib.core.CodeGenerationException: java.lang.reflect.InaccessibleObjectException-->Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @6b419da
at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:545)
at org.springframework.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:367)
at org.springframework.cglib.proxy.Enhancer.generate(Enhancer.java:575)
at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData.lambda$new$1(AbstractClassGenerator.java:103)
at org.springframework.cglib.core.internal.LoadingCache.lambda$createEntry$1(LoadingCache.java:52)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.springframework.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:57)
at org.springframework.cglib.core.internal.LoadingCache.get(LoadingCache.java:34)
The text was updated successfully, but these errors were encountered:
I can not use Spring's Sort function to access generic fields in entities (I'm using Spring Boot 3.1.5, Hibernate 6.2.3). Here is my entity code:
Here is how I use Spring's Sort to access the
displayName
field, in which entity isAbstractLogDetail
's generic field:Here is the error:
I think it's because the type "E entity" was transformed to Object after being compiled. I even tested TypedSort to see if it can access the generic field:
But seems like Spring can not create a proxy, I got this error:
The text was updated successfully, but these errors were encountered: