How to fill non column field of entity in room library

前端 未结 4 1385
天命终不由人
天命终不由人 2021-02-01 21:00

I have a class entity as below

@Entity
public class Task {    
    private String name; 
    private Integer ParentId;
    private Integer userId;   
    @Ignore         


        
4条回答
  •  北荒
    北荒 (楼主)
    2021-02-01 21:14

    You should move the @Ignore field outside of the constructor, like this:

    Sample data:

    @Entity(primaryKeys = ["id"])
    data class User(
        @SerializedName("id")
        val id: Int,
    
        @SerializedName("name")
        val name: String,
    
        @SerializedName("age")
        val age: Int
    ) {
       @Ignore
       val testme: String?
    }
    

    Refer github discussion for more details

提交回复
热议问题