Hi,
I have a domain model that looks like this
Category 1 ------- * Type 1 ------- * Expense
Or in English "An expense has a type, and each type belongs to a category". I want to write a Criteria query that will find all expenses in a particular category. I tried both this
Expense.withCriteria {
eq('type.category', someCategoryInstance)
}
and this
Expense.withCriteria {
type {
eq('category', someCategoryInstance)
}
}
But neither of them work, what am I missing?
Update
I've been asked to show the domain classes, so here they are:
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
}