Update some specific field of an entity in android Room

前端 未结 7 1621
臣服心动
臣服心动 2020-11-29 16:45

I am using android room persistence library for my new project. I want to update some field of table. I have tried like in my Dao -

// Method 1         


        
7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-29 17:26

    I want to know how can I update some field(not all) like method 1 where id = 1

    Use @Query, as you did in Method 2.

    is too long query in my case because I have many field in my entity

    Then have smaller entities. Or, do not update fields individually, but instead have more coarse-grained interactions with the database.

    IOW, there is nothing in Room itself that will do what you seek.

    UPDATE 2020-09-15: Room now has partial entity support, which can help with this scenario. See this answer for more.

提交回复
热议问题