这是我的模型课
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个数据。