ORMLite查询异物时,会为其ID以外的字段提供空值

时间:2019-04-26 06:36:00

标签: android kotlin ormlite

我有两个模型类,一个是外键。将数据持久保存在ormlite中时,会正确插入数据,但是从dao异物字段查询数据时,其id除外的值为空值。

Home.class

@DatabaseTable(tableName = "Home")
class Home: Serializable {

    @DatabaseField(id = true)
    var id: Long? = null

    @DatabaseField(columnName = "name")
    var name: String? = null

    @DatabaseField(columnName = "dateCreated")
    var dateCreated: String? = null

    @DatabaseField(columnName = "lastUpdated")
    var lastUpdated: String? = null
}

Flat.class

@DatabaseTable(tableName = "Flat")
    class Flat: Serializable {

    @DatabaseField(id = true)
    var id: Long? = null

    @DatabaseField(canBeNull = false, foreign = true, columnName = "homeId", foreignAutoRefresh = true)
    var home: Home? = null

    @DatabaseField
    var districtCode: String? = null

    @DatabaseField
    var name: String? = null

    @DatabaseField
    var dateCreated: String? = null

    @DatabaseField
    var lastUpdated: String? = null

}

当我从ormlite db中获取Flat行时,我会获得Flat模型及其异物模型的值,即Home菲尔德除其ID外为空

0 个答案:

没有答案