I'm wondering how to inhire to a data class in Room database. As example a have something like this
@Entity(tablename = "user")
abstract class User {
var name: String,
var id: Int
}
Now I want to create a specific user, that has all the attributes of the User class as an entity to store and load them from database
@Entity(tablename = "user")
data class FreeUser {
override var name: String,
override var id: Int,
var freeUserAttirbute: String
} : User ()
and
@Entity(tablename = "user")
data class PremiumUser {
override var name: String,
override var id: Int,
var premiumUserAttirbute: String
} : User ()
as a DAO I would write something like this
interface UserDao {
@Query("SELECT * FROM 'user'")
fun getAllUser(): List<User>
Now when I build my application room is telling me, that the User
class can't be abstract. How can I solve this inheritance issue in data class and Room?