Reputation: 49371
Let's say I have a domain class called ShopCategoryPageTab. And I have a domain class called Product.
I want ShopCategoryPageTab to have a list of Products. However, this list is not static, but determined by a formula.
For example, I might want to have a "products" property which would list all products with criteria X, Y Z.
So this property/list is not entered manually by someone, it is dynamically generated. (products can be removed/added by an external applications, product properties could be changing).
Is there such a thing?
Upvotes: 1
Views: 2210
Reputation: 1532
Agree with @Burt above.. alternatively you can also call your methods as getXProduct() or getYProduct() and access them as fields instead of methods.
The fields would be like XProduct and YProduct. You'll have to mark these fields transients explicitly..
Hope it helps..
Upvotes: 0
Reputation: 75671
Often you call the dynamically added methods like list(), findAll(), findByFooAndBar(), etc., but you can always add your own. So in your case you'd create something like this:
class ShopCategoryPageTab {
...
List findAllProductsByXYZ(x, y, z) {
...
}
}
Name it however you like of course, and the implementation will be a criteria query or an HQL query via executeQuery().
Upvotes: 2