
Originally Posted by
Arthur Loder
However, most likely you have a DAO method to retrieve a User. To get all of the subscriptions, a getSubscriptions() call will work. But to get the active subscriptions, what are the alternatives? Embed a DAO in the User object (which some people seem passionately against) to achieve this? If I issue a query to get all Users who signed up one year ago, I then want to simply call getActiveSubscriptions() on each User; I don't want to have to use some other DAO to get the active ones.
I guess my question is this: can I define methods on my persistent class that do not correspond to persistent properties? For instance, can you have an "activeSubscriptions" property/method that defines the filtering criteria? In that case, you could arbitrarily add methods on persistent domain objects corresponding to various filtering on persistent sets. I think this would be ideal; the actual query would be filtered on the database-side, but it would be handled transparently by Hibernate so you can simply query for a User and then invoke any methods you want (without embedding a DAO in the User or using a different DAO and passing the User as an argument).
Does Hibernate support this?