暴露的查询返回null

时间:2019-06-12 16:50:35

标签: kotlin-exposed

我在xposed上遇到困难。 我有以下模型:

class LegalPerson(id: EntityID<UUID>) : UUIDEntity(id) {
    companion object : UUIDEntityClass<LegalPerson>(LegalPersonTable)

    var internalId by LegalPersonTable.internalId
    var companyId by LegalPersonTable.companyId
    var active by LegalPersonTable.active
    var tradeName by LegalPersonTable.tradeName
    var fantasyName by LegalPersonTable.fantasyName
    var email by LegalPersonTable.email
    var cnpj by LegalPersonTable.cnpj
    var stateRegistration by LegalPersonTable.stateRegistration
    var muninipalRegistration by LegalPersonTable.muninipalRegistration
    var address by LegalPersonTable.address
}

object LegalPersonTable : UUIDTable("person.legal_person") {
    val internalId = long("internal_id").autoIncrement().uniqueIndex()
    val companyId = uuid("company_id")
    val active = bool("active")
    val tradeName = varchar("trade_name", 100)
    val fantasyName = varchar("fantasy_name", 100)
    val email = varchar("email", 100)
    val cnpj = varchar("cnpj", 18)
    val stateRegistration = varchar("state_registration", 20)
    val muninipalRegistration = varchar("municipal_registration", 20)
    val address = uuid("address")
}

// *** PHONE ***

class Phone(id: EntityID<UUID>) : UUIDEntity(id) {
    companion object : UUIDEntityClass<Phone>(PhoneTable)

    var internalId by PhoneTable.internalId
    var phone by PhoneTable.phone
    var idLegalPerson by LegalPerson referencedOn PhoneTable.idLegalPerson
}

object PhoneTable : UUIDTable("person.phone_legal_person") {
    val internalId = long("internal_id").autoIncrement()
    val phone = uuid("phone")
    val idLegalPerson = reference("id_legal_person", LegalPersonTable.id, ReferenceOption.CASCADE)
}

所以我这样做:LegalPerson.all() 但这总是使我返回null。 而且我在数据库中有数据。 我的关系是一对多的。其中1个法人-N个电话 我要去哪里错了?

0 个答案:

没有答案