This works: ```@SolrDocument(solrCoreName ="indexe...
# getting-started
b
This works:
Copy code
@SolrDocument(solrCoreName ="indexedcitation")
class IndexedCitation {
    @Id
    @Indexed(name = "id", type = "string")
    private var id: String? = null

    @Indexed(name = "title", type = "string")
    private var title: String? = null


    fun getId(): String? {
        return id
    }

    fun setId(id: String?) {
        this.id = id
    }

    fun getTitle(): String? {
        return title
    }

    fun setTitle(title: String?) {
        this.title = title
    }
}
but not:
Copy code
@SolrDocument(solrCoreName ="indexedcitation")
data class IndexedCitation(
    @Id
    @Indexed(name = "id", type = "string")
    private var id: String? = null,

    @Indexed(name = "title", type = "string")
    private var title: String? = null

)
p
You can specify for which element annotation should be used: https://kotlinlang.org/docs/reference/annotations.html#annotation-use-site-targets
b
so correct me if I'm wrong but in that case it would be @field:String ?
p
@field:Id
I don’t know which target you need (field, set or get), you can try several.
b
I can't set these on the @Indexed parameters
and trying all combinations on @Id do not change anything (the only one that work on @Indexed is field.
bytecode of the dataclass
bytecode of the public class
(no idea if it is useful or not)
ok it seems that the problem arises when I have a constructor
r
Do you use allopen plugin? the classes are final in the bytecode you posted and spring doesn't like final classes - it can give weird errors.
b
what is that plugin?
Is there any expected negative side effect of using that plugin?
r
not really
👌 1
all your classes will be open by default just like in Java
there is also kotlin-spring plugin, which works the same way but only for classes annotated with Spring annotations
definitely worth applying before testing spring with kotlin
b
first time I get stung by that but yep I'll clearly try that
But I cannot make data classes open
seems to work anyway. Thanks