私はこのようなドメインモデルを持っています
Category 1 ------- * Type 1 ------- * Expense
または英語で「経費にはタイプがあり、各タイプはカテゴリに属します」。特定のカテゴリのすべての費用を検索する基準クエリを作成したいと考えています。私はこれを両方試しました
Expense.withCriteria {
eq('type.category', someCategoryInstance)
}
この
Expense.withCriteria {
type {
eq('category', someCategoryInstance)
}
}
しかし、どちらも機能しません。何が欠けていますか?
アップデート
ドメイン クラスを表示するように依頼されたので、以下に示します。
public class Category {
String description
static hasMany = [types: Type]
}
public class Type {
String description
static hasMany = [expenses: Expense]
static belongsTo = [category: Category]
}
public class Expense {
static belongsTo = [type: Type]
Date date
String description
float amount
}