The other way to express this is with generics, `c...
# announcements
k
The other way to express this is with generics,
class Entity<D: Int?>(val id: D)
and then keep the nullability in the type throughout the code.
c
how do I create a new
Entity
in this case? the
id
has to be
null
for hibernate to generate it, but with
val id: D
I cannot assign
null
to
id
k
D
can be nullable, right?
c
Oh, now I see what you meant. Thanks 🙂
Nope, I was right, doesn't work
class Entity<T: Long?>(val id: T = null)
there is an error:
Null
can not be a value of a non-null type
T