After updating Spring Boot from 3.1 to 3.2, I followed the instructions to add the -parameters flag for Java compilation. Despite this, I’m still encountering the same error, indicated by the stack trace I received.
**org.springframework.data.mapping.MappingException: Parameter org.springframework.data.mapping.Parameter@57ced0b5 does not have a name**
at org.springframework.data.mapping.model.PersistentEntityParameterValueProvider.getParameterValue(PersistentEntityParameterValueProvider.java:61)
at org.springframework.data.mapping.model.ClassGeneratingEntityInstantiator.extractInvocationArguments(ClassGeneratingEntityInstantiator.java:301)
at org.springframework.data.mapping.model.ClassGeneratingEntityInstantiator$EntityInstantiatorAdapter.createInstance(ClassGeneratingEntityInstantiator.java:273)
at org.springframework.data.mapping.model.ClassGeneratingEntityInstantiator.createInstance(ClassGeneratingEntityInstantiator.java:98)
at org.springframework.data.redis.core.convert.MappingRedisConverter.doReadInternal(MappingRedisConverter.java:222)
at org.springframework.data.redis.core.convert.MappingRedisConverter.readInternal(MappingRedisConverter.java:180)
at org.springframework.data.redis.core.convert.MappingRedisConverter.readCollectionOrArray(MappingRedisConverter.java:818)
at org.springframework.data.redis.core.convert.MappingRedisConverter.readProperty(MappingRedisConverter.java:284)
at org.springframework.data.redis.core.convert.MappingRedisConverter$ConverterAwareParameterValueProvider.getPropertyValue(MappingRedisConverter.java:1092)
at org.springframework.data.redis.core.convert.MappingRedisConverter$ConverterAwareParameterValueProvider.getPropertyValue(MappingRedisConverter.java:1075)
at org.springframework.data.mapping.model.PersistentEntityParameterValueProvider.getParameterValue(PersistentEntityParameterValueProvider.java:71)
at org.springframework.data.mapping.model.ClassGeneratingEntityInstantiator.extractInvocationArguments(ClassGeneratingEntityInstantiator.java:301)
at org.springframework.data.mapping.model.ClassGeneratingEntityInstantiator$EntityInstantiatorAdapter.createInstance(ClassGeneratingEntityInstantiator.java:273)
at org.springframework.data.mapping.model.ClassGeneratingEntityInstantiator.createInstance(ClassGeneratingEntityInstantiator.java:98)
at org.springframework.data.redis.core.convert.MappingRedisConverter.doReadInternal(MappingRedisConverter.java:222)
at org.springframework.data.redis.core.convert.MappingRedisConverter.read(MappingRedisConverter.java:174)
at org.springframework.data.redis.core.convert.MappingRedisConverter.read(MappingRedisConverter.java:105)
at org.springframework.data.redis.core.RedisKeyValueAdapter.get(RedisKeyValueAdapter.java:290)
at org.springframework.data.redis.core.RedisKeyValueAdapter.getAllOf(RedisKeyValueAdapter.java:374)
at org.springframework.data.redis.core.RedisKeyValueAdapter.getAllOf(RedisKeyValueAdapter.java:341)
at org.springframework.data.keyvalue.core.KeyValueTemplate.lambda$findAll$2(KeyValueTemplate.java:216)
at org.springframework.data.keyvalue.core.KeyValueTemplate.execute(KeyValueTemplate.java:314)
at org.springframework.data.keyvalue.core.KeyValueTemplate.executeRequired(KeyValueTemplate.java:329)
at org.springframework.data.keyvalue.core.KeyValueTemplate.findAll(KeyValueTemplate.java:214)
at org.springframework.data.keyvalue.repository.support.SimpleKeyValueRepository.findAll(SimpleKeyValueRepository.java:108)
at org.springframework.data.keyvalue.repository.support.SimpleKeyValueRepository.findAll(SimpleKeyValueRepository.java:42)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:352)
at org.springframework.data.repository.core.support.RepositoryMethodInvoker$RepositoryFragmentMethodInvoker.lambda$new$0(RepositoryMethodInvoker.java:277)
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:516)
at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:285)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:628)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:168)
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:143)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
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.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:249)
**at jdk.proxy3/jdk.proxy3.$Proxy157.findAll(Unknown Source)**
2
Answers
Try adding @AllArgsConstructor or @RequiredArgsConstructor on the POJO which is giving this error. It should be resolved then.
The Spring Data update causes this exception due to parameter name retention: "… code within the Spring Framework and Spring portfolio frameworks no longer attempts to deduce parameter names by parsing bytecode".
Adding a
@NoArgsConstructor
can be the first way to solve because "…If an entity contains a field of some type which is defined in another package, a mapping exception will be thrown during a read operation if said object doesn’t provide an empty constructor (private, protected or public)" (Spring Data MongoDb issue).If there is no opportunity to do that, you can add compiler argument (see this question). However, there is a certain risk of exposing sensible information using this approach, for details see this case study.