Hi, I have a simple entity: `Ent(val id: Long?) : ...
# spring
c
Hi, I have a simple entity:
Ent(val id: Long?) : Persistable<Long?>
. This of course requires to implement
getId
and
isNew
. But when I try to implement
getId
I have Platform declaration clash error; if I don't implement it, I have Class Ent must be declared abstract or implement abstract method error. What's the correct way to do this?
u
czar: what about using secondary constructor?
@Czar and another workaround can be backing that field
c
@ugurk I don't see how that helps, can you provide an example using my
Ent
class?
u
making that variable private solves it
class Ent(private val id: Long) : Persistable<Long?>
👍 1
this should work, compiled and run successfully
c
It does, thank you! Looks like a hack, but not too ugly and it works, so I'm happy (for now) 🙂
s
Btw this compiles fine in 1.1.3
Copy code
class Ent(val id:Long) : Persistable<Long> {
  override fun isNew(): Boolean {
    return false
  }

  override fun getId(): Long {
    return this.id
  }
}
c
@strelok, of course it does, but an Entity id must be
Long?
not
Long
and that does not compile.