https://kotlinlang.org logo
#spring
Title
# spring
g

George

01/18/2023, 3:44 PM
Hi folks, anyone getting the error:
Copy code
No accessor to set property @org.springframework.data.annotation.Id() @org.springframework.data.relational.core.mapping.Column(value="id")private final int org.msensis.imahub.hub.core.internal.entities.MessageEntity.id
java.lang.UnsupportedOperationException: No accessor to set property @org.springframework.data.annotation.Id() @org.springframework.data.relational.core.mapping.Column(value="id")private final int org.msensis.imahub.hub.core.internal.entities.MessageEntity.id
While using data classes for entities? Thanks in advance for any answers
Found a relative issue :https://github.com/spring-projects/spring-data-commons/issues/1810?focusedCommentI[…]tlassian.jira.plugin.system.issuetabpanels%253Acomment-tabpanel but the solution states to use data class. Though my class is already a data class. Kind of noteworthy is that i get this exception after i convert some of my fields (not the id) into classes rather than primitives, etc strings -> uuid, someOtherId ->TypeOfId etc
d

Davio

01/18/2023, 4:47 PM
Make sure you added Kotlin's jpa plugin to the list of compiler plugins, this forces classed annotated with Entity to be open
g

George

01/18/2023, 4:50 PM
i have
kotlin("plugin.spring")
which i think it also applies
kotlin-allopen
.
Trying answering my own question, probably it is because i use value classes as fields and spring's reflection cannot use the right
copy()
constructor (just a guess from browsing spring's github's issues) to mutate my id field (which it is just a primitive Int) when i insert the object and waiting for the db to assign it an id.
188 Views