greenDao使用遇到的坑

  1. 编译报警告
    WARNING: API 'variant.getJavaCompiler()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()'.
    It will be removed at the end of 2019.
    For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
    To determine what is calling variant.getJavaCompiler(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace.
    Affected Modules: app

    原因:gradle版本过高,3.3以上不行。需要修改项目的gradle

    dependencies {
            classpath 'com.android.tools.build:gradle:3.2.1'
            classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2'
        }

     

  2. 主键自增长无效。解决方法:

    
      /**
      * 1.要确保注解为true,
      * 2.主键类型必须为Long
      */
      @Id(autoincrement = true)
      private Long id;

     

  3. 字段使用boolean,查询要注意
    boolean字段查询要用 1,0不能使用true,false

     

    4.默认开启缓存的,如果查询数据不对,需要在查询前清除缓存

dao.detachAll();


 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值