I have a service that prepares a table (not persisted) of statistics generated from 4 persisted tables.
Currently, I am approaching this by implementing a view in my database that will get the statistics in a very optimal way. Then I plan to map the view to an object so that I can easy obtain the objects, page, and sort using Hibernate.
Alternatively, I could do this all with the domain objects. However, due to the calculations and the sheer number of objects this appears to be roughly 10 times as slow in Hibernate 2.0.3. Of course, this is not a fault in Hibernate.
My question is: is this considered a best practice? On one side I am gaining significant performance, on the other I am losing some of the nice database abstraction and caching I get from Hibernate.
It seems to me that I should leverage Hibernate wherever possible and only do this view approach when I can get significant performance improvements. However, I am curious about the experience of other Hibernate users and developers.
|