Grails 域类findAll无效查询-查询语法

Grails 域类findAll无效查询-查询语法,grails,Grails,我试图将findAll与mysql的查询字符串一起使用。同样的查询在mysql工作台上也可以正常工作。非常感谢你的指点,谢谢 //find all subscriptions expiring 7 days from now Subscription.findAll("from subscription where expires=date_add(CURDATE(), INTERVAL 7 DAY)") 错误: Invalid query [from subscription where e

我试图将
findAll
与mysql的查询字符串一起使用。同样的查询在mysql工作台上也可以正常工作。非常感谢你的指点,谢谢

//find all subscriptions expiring 7 days from now
Subscription.findAll("from subscription where expires=date_add(CURDATE(), INTERVAL 7 DAY)")
错误:

Invalid query [from subscription where expires=date_add(CURDATE(), INTERVAL 7 DAY)] for domain class

它不起作用,因为
findAll
采用了而不是普通的SQL

有很多方法可以编写查询
findAllBy
并应完成以下工作:

import groovy.time.TimeCategory    

use( TimeCategory ) {
    Subscription.findAllByExpires(7.days.from.now)
}

我假设
Subscription
域类具有属性
expires

@dmahapatro:谢谢您的修订:)