https://kotlinlang.org logo
#exposed
Title
# exposed
m

mp

09/01/2020, 10:11 AM
hi there. guys if we assume that we have some kind of sealed hierarchy of classes (with common fields in base classes, and some specific in the, subclasses)
Copy code
sealed class A {
    abstract val a: Int

    data class B(val b: String, override val a: Int) : A()
    data class C(val c: Boolean, override val a: Int) : A()
}
persist those B,C classes to single table, with nullable b and c fields - make it any sense from exposed point of view? I’ve tried to google some samples for this but without success. thats why interesting to ask about it( maybe this idea some example of sick imagination of mine 😃)
t

tapac

09/03/2020, 7:56 AM
Do you want to implement this sealed class as and Entity?
m

mp

09/03/2020, 9:19 AM
when we speak about rest controllers sealed class allow us to rouse similar dtos(like 1 field difference) I also saw previously that hibernate have some strategies to persist class hierarchies as single table. thats why I’ve got this guess that - maybe sealed class hierarchy also can be persisted in similar way. But IDK exactly and assume that my suggestion can be wrong - but is it so or not - I can’t find in google 😃