-
Notifications
You must be signed in to change notification settings - Fork 678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KotlinBeanInfoFactory
does not consider overridden bean property accessors
#3140
Comments
As per Kotlin, your class doesn't define any properties hence Mixing properties regarding their origin isn't supported. The purpose of |
Well. My Java superclass is generated and i need to set one specific field as the id. My workaround is to turn the entity into a java class but that defeats the purpose of using kotlin. |
KotlinBeanInfoFactory
does not consider overridden bean property accessors
We can introduce accessor specialization to detect getters and specialize accessor methods if the type hierarchy declares overrides. The only constraint however is that property names must be unique. |
We now attempt to detect property accessors for properties declared in Kotlin that do not have a Kotlin-style accessor but one that instead comes from an interface. Also, we specialize accessor methods that are inherited from a Java superclass but override accessors in the Kotlin realm. Closes #3140 Closes #3146
We now attempt to detect property accessors for properties declared in Kotlin that do not have a Kotlin-style accessor but one that instead comes from an interface. Also, we specialize accessor methods that are inherited from a Java superclass but override accessors in the Kotlin realm. Closes spring-projects#3140 Closes spring-projects#3146
I have the same issue, but I'm not using Kotlin - just plain Java 21. After upgrading to 3.3.3 I get Edit: I've override the methods from the base class and it works again - it seems that the projection have lost the ability to look into the super class(es) for the method. |
What is the issue?
With the introduction of Spring Boot 3.2, a behaviour by the KotlinBeanInfoFactory class is causing a problem of ignoring annotated getters in a Kotlin class and instead using getters from its (java) superclass.
How to reproduce?
You can reproduce this issue by creating a class in Kotlin and a superclass in Java. Annotate the getter in the Kotlin subclass with @id and observe that KotlinBeanInfoFactory does not recognize it.
Java Superclass:
Kotlin Entityclass:
The intent is to enhance a generated java class with a certain field to be the id field of the collection.
Further analysis
KotlinBeanInfoFactory reads properties only from its Kotlin class and disregards any annotated getters. The resulting BeanInfo object includes a PropertyDescriptor for 'name', however, the getter for this property is acquired from the superclass, which does not carry any annotations. Thus, it seems like the 'id' field is not being properly initialized.
What did I expect?
The expected behavior is that KotlinBeanInfoFactory should recognize and prioritize annotated getters in a Kotlin subclass over those in its Java superclass, ensuring proper initialization of the 'id' field and other properties.
The text was updated successfully, but these errors were encountered: