Regular |
 |
Joined: Mon Jul 26, 2004 2:28 pm Posts: 86 Location: Pensacola, Florida
|
The impression I got after reading Hibernate in Action is that it is best to keep business logic in the model and try to limit the DAOs to persistence concerns. The flow kind of went like this:
1. Load something from the DAOs
2. Pass result to business object method(s)
3. Get result(s) from business object method(s)
4. Pass result to DAOs
However, for performance reasons it makes sense to execute the logic in HQL, as the database is much more efficient at queries. What you could do is create a DAO method called getOpenOrdersWithPendingItems( ) that executes the HQL you mentioned. Although you are implementing logic in the query, you are not hiding it because the method does exactly what it says and it's not tied to a use case. A bad name would be getModifiableOrders( ), since that doesn't tell you what kind of selection criteria is being imposed and does tie itself to a use case.
- Jesse
|
|