Hi,
I've a quite complex piece of buissness-logic which executes quite a lot of database queries and because of that is painfully slow.
What I've done in some areas is to replace database-queries with HashMaps, fetching all data at the beginning into a HashMap,
and looking up the actually needed result by key. However thats a really bad thing for code-quality and maintainability :/
Is there some way to make hibernate re-use the results from an already executed query, if its obvious that it already has all the looked-up'ed items loaded before?
Something like:
Code:
manager.createQuery("From Booking b WHERE b.nrOfTickets > 0 AND b.nrOfTickets < 100").getResultList();
for(int i=1; i < 10; i++) {
manager.createQuery("From Booking b WHERE b.nrOfTickets ="+i+"").getResultList(); //No need to ask the database
}
Thank you in advance, Clemens