Hi,
I'm currently using a Sphinx search engine to search through some rows in a table. This then returns a list of 20 ids to be shown on my listings page.
What I'd like to be able to do is use Hibernate to return the full objects for these ids. Many of the the more popular objects will be stored in the secondary level cache and it occured to me that in theory, for many searches I should be able to retrieve these objects without hitting the database at all.
But how to do it?
I've tried an HQL query with an IN (:idList) clause but this does hit the database even though in theory it doesn't need to. I've also tried a similar thing with a criteria query but this does the same.
I could loop though the list and do 20 load()s but this seems pretty inefficient, especially when the cache isn't warmed up.
Is there a better way of loading a list of objects where the ids are known?
Many thanks Ian
|