Update some specific field of an entity in android Room -
i using android room persistence library new project. want update field of table. have tried in dao
-
method 1:
@dao public interface tourdao { @update int updatetour(tour tour); }
but when try update using method updates every field of entity matches primary key value of tour object. have used @query
method 2:
@query("update tour set endaddress = :end_address id = :tid) int updatetour(long tid, string end_address);
it working long query in case because have many field in entity. want know how can update field(not all) method 1
id = 1;(id auto generate primary key).
entity: @entity public class tour { @primarykey(autogenerate = true) public long id; private string startaddress; private string endaddress; //constructor, getter , setter }
i want know how can update field(not all) method 1 id = 1
use @query
, did in method 2.
is long query in case because have many field in entity
then have smaller entities. or, not update fields individually, instead have more coarse-grained interactions database.
iow, there nothing in room seek.
Comments
Post a Comment