尝试从RealmList获取数据时,大小为0,即使我在realm studio中读取了realmList并看到了6个数据

时间:2019-05-27 11:30:23

标签: java android kotlin realm

这是我的模型课

open class Biller_Type_Data_Model : RealmObject(){

    @PrimaryKey
    var biller_type_id: String? = ""
    @Required
    var biller_type: String? = ""
    @Required
    var biller_type_code: String? = ""
    @Required
    var biller_type_name: String? = ""

    var biller_data_models : RealmList<Biller_Data_Model>? = RealmList()

    var last_update: String? = null
} 

private fun initRealm() {

        var mBillerTypesFindFirst = realm!!.where(Biller_Type_Data_Model::class.java)
                .equalTo("biller_type_code", "PLS")
                .findFirst()

        var resultBillerData= mBillerTypesFindFirst!!.biller_data_models!!

        var type_name = mBillerTypesFindFirst!!.biller_type_name

        Timber.d("RESULT BILLER DATA : ${resultBillerData!!.size}")
}

如果我尝试获得resultBilerData的大小,则结果Timber为:

结果帐单数据:0

但是如果我使用Java,则上面的代码可以成功在RealmList中获取6个数据。

0 个答案:

没有答案