【问题标题】:ActiveAndroid custom primary key for Create and Update Record用于创建和更新记录的 ActiveAndroid 自定义主键
【发布时间】:2015-11-16 23:30:08
【问题描述】:

这是我的模型,我自己维护 id。

表(名称 = “主”) 公共类大师扩展模型{

@Column(name = "masterId")
public int id;

@Column(name = "name")
public String name;

@Column(name = "description")
public String description;

}

如何将我的自定义列设置为主列,支持创建和更新。

【问题讨论】:

    标签: activeandroid


    【解决方案1】:

    @table 注释中的用户 ID 用于定义您的自定义 ID

    @Table(name = "Items", id = "_id")
    public class Master extends Model {
    
        @Column(name = "masterId")
        public int id;
    
        @Column(name = "name")
        public String name;
    
        @Column(name = "description")
        public String description;
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-01
      • 1970-01-01
      • 2015-09-26
      • 2017-12-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多