我正在查看我当前项目中的一些 grails gorm 代码,我想知道以下 HQL 方法的优缺点是什么:
UploadUpsell.executeUpdate("update UploadUpsell set processedStatus=:newStatus, processedDate=:processedDate where processedDate is null and period=:period",
[newStatus: EXPIRED_UPSELL_STATUS, processedDate: new Date(), period: flow.period])
我本来会采用更惯用的方法
UploadUpsell.findAllByPeriodAndProcessedDate(flow.period, null).each { UploadUpsell uploadUpsell ->
uploadUpsell.with {
processedStatus = EXPIRED_UPSELL_STATUS
processedDate = new Date()
save()
}
}
我相信我的方法会更具可测试性并且更具可读性,但我想知道我的想法是否只是教条
据我所知,grails 模拟框架不支持 HQL 语句。