Quote:
There is another method getHighSalariedEmployees()
which returns employees with salaries greater than 100,000. I can execute an HQL query inside getHighSalariedEmployees() .
But I don't want query-definition and -execution code inside my business object Department.
Suggestions?
MVC / DAO mismatch
you can access data layer from your domain model but everyone will advise you not to do it for a lot of good reasons.
3 solutions with Hibernate 2:
- let hibernate retrieve the full list and lets filter it in java (not really performant depending on list size)
- map a second collection with a "where saliaries > 100000" clause
- just let the controller do this stuff, it's exactly what it should do
2 bests solutions with hibernate 3:
- use dynamic filter
- use lazy formula property
these two features are EXCELLENT and solve the data access problems