我正在将Spring数据与Kotlin一起使用。我有几个问题:
interface CompanyShareholderTransactionsRepository: CrudRepository<CompanyShareholderTransactionsTable, UUID> {
@Query("""
select folio_no as folioNo, name, cert_no, dist_no_from, dist_no_to, date_acq
from company_shareholder_transactions txn
inner join company_shareholder_certs cert on txn.shareholder_certs_id = cert.id
inner join company_shareholders_info info on txn.shareholder_info_id = info.id
where txn.company_id = :companyId and
txn.shareholder_certs_id = :certId
order by txn.date_acq limit 1
""" , nativeQuery = true)
fun getTransactionInfoByCertId(companyId: UUID, certId: UUID): TransactionInfo?
}
interface TransactionInfo {
val folioNo: Int
val name: String
val cert_no: Int
val distNoFrom: BigInteger
val distNoTo: BigInteger
val dateAcq: LocalDate
}
仅举一个有效的例子,
folioNo在sql中使用别名。
cert_no工作正常。
但是dist_no_from,dist_no_to和date_acq不会映射到TransactionInfo变量。
我正在寻找一种无需一直输入别名的方法。