I have a class entity as below
@Entity
public class Task {
private String name;
private Integer ParentId;
private Integer userId;
@Ignore
I faced the same problem a few days ago and had a look at this thread. I am using Kotlin data
classes for creating database entities. Given that Kotlin data classes do not play well with inheritance subclassing was not a viable option. My solution was to use the @Embedded
keyword in a wrapping class, as follows:
data class TaskToDisplay(@Embedded
var task: Task,
var noOfSubTask: Int = 0)
This solution does not create an additional column in the database and most importantly matches all Task's fields with Room's response columns.