GreenDao主键自增的坑

android使用GreenDao数据库框架创建entity类

@Entity
public class User {

    @Id(autoincrement = true)
    private Long id;
    @Property(nameInDb = "name")
    private String userName;
    private int age;
    private String address;
    @Generated(hash = 1932566844)
    public User(Long id, String userName, int age, String address) {
        this.id = id;
        this.userName = userName;
        this.age = age;
        this.address = address;
    }
其中,自增使用的id必须是Long类型,而非long类型 不然不会自增


你可能感兴趣的:(GreenDao主键自增的坑)