I'm trying to use a room entity with a value class:
@JvmInline
value class UserToken(val token: String)
and the entity:
@Entity(tableName = TABLE_AUTH_TOKEN)
data class TokenEntity(
@PrimaryKey val id: Int = 0,
val token: UserToken
)
I get the following error:
error: Entities and POJOs must have a usable public constructor. You can have an empty constructor or a constructor whose parameters match the fields (by name and type).
public final class TokenEntity {
^
is it even possible to use room with value class? I couldn't find anything about this. thanks
See the comment from @CommonsWare. Android does not yet support value classes for Room.
Here is a possible explanation according to Kotlin Inline Classes in an Android World.