Grails アプリに次のようなドメイン クラスがあります。
class Event {
Date date
}
特定の年の特定の月に発生したイベントを選択する条件クエリを作成したいのですが、何か提案はありますか?
ありがとう、ドン
Grails アプリに次のようなドメイン クラスがあります。
class Event {
Date date
}
特定の年の特定の月に発生したイベントを選択する条件クエリを作成したいのですが、何か提案はありますか?
ありがとう、ドン
あなたはおそらくただ使うことができますbetween
:
def firstDayOfMonthInYear, lastDayOfMonthInYear;
/* set the two values using Calendar or some other mechanism */
Event.withCriteria {
between('date', firstDayOfMonthInYear, lastDayOfMonthInYear)
}
包括性についてはbetween
よくわかりません。両端が包括的でない場合は、開始日と終了日を調整する必要があります。