Can I use `data class`es for JPA Entities having e...
# announcements
k
Can I use `data class`es for JPA Entities having equals only on
id
and the other using
val
somehow? In order to generate
equals()
only of
id
it has to be the only argument in the primary constructor.
Copy code
@Entity
data class Term(
        @Id
        val id: UUID,

        val name: String
) {

    val definition: Definition = Definition.DEFAULT

    constructor(id: UUID, name: String, definition: Definition) : this(id, name) {
        this.definition = definition
    }
}
I think I'd like to do someting like this …
g
Maybe just move id from constructor to body? Not perfect, of course, but it’s the only way to exclude id from equals/hashcode