Closed
Description
Just upgraded to spring boot 3.3.3 and I'm having a problem with Projections. I'm currently using
Spring Boot: 3.3.3
Kotlin: 2.0.20
Created a sample project to test it easily and on this one I decided to downgrade Koltin to version 1.9.25.
@Entity
@Table(name = "test")
class Entity(
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private val _id: Long? = null,
val name: String
): Persistable<Long> {
override fun getId(): Long? = _id
override fun isNew(): Boolean = _id == null
}
interface Repository: JpaRepository<Entity, Long> {
@Query("select e from Entity e")
fun findAllProjections(): List<EntityProjection>
}
interface EntityProjection {
val id: Long
val name: String
}
For some reason with the new version. I cannot longer access the id using the EntityProjection interface. I get the error:
Invoked method is not a property accessor
java.lang.IllegalStateException: Invoked method is not a property accessor
at org.springframework.data.projection.PropertyAccessingMethodInterceptor.invoke(PropertyAccessingMethodInterceptor.java:66)
at org.springframework.data.projection.ProjectingMethodInterceptor.invoke(ProjectingMethodInterceptor.java:71)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
at org.springframework.data.projection.ProxyProjectionFactory$TargetAwareMethodInterceptor.invoke(ProxyProjectionFactory.java:243)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:223)
at jdk.proxy3/jdk.proxy3.$Proxy157.getId(Unknown Source)
at com.example.projections.RepositoryTest.test(RepositoryTest.kt:17)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
If I force the version of data bom to 2024.0.2 everything works again and I'm able to access the id using the projection