查找一年之内的数据库的记录,sql的写法
select * from sub_account_record where operate_type='INCOME' and transaction_type='ONLINE_RECHARGE' and transaction_time >( now()-interval '1 year')
spring boot jpa 的代码的中的写法
override fun isCashAccount(tenantId: Long): Boolean {
val queryWrapper: QueryWrapper<SubAccountRecord> = QueryWrapper<SubAccountRecord>()
queryWrapper.allEq(mapOf("tenant_id" to tenantId, "transaction_type" to TransactionType.ONLINE_RECHARGE, "operate_type" to OperateType.INCOME))
queryWrapper.ge("transaction_time",LocalDateTime.now().minusYears(1L))
return subAccountRecordDao.selectCount(queryWrapper)>0
}
jpa打印出来的sql日志为
SELECT COUNT( * ) FROM sub_account_record WHERE deleted=0 AND (tenant_id = 1453580696349184000 AND transaction_type = 'ONLINE_RECHARGE' AND operate_type = 'INCOME' AND transaction_time >= '2020-11-19T15:47:17.784938900')
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://blog.csdn.net/sunyuhua_keyboard/article/details/121424570
内容来源于网络,如有侵权,请联系作者删除!