While executing the query, it takes long time and responds with out of memory error.
I'm no expert here, but I have a few ideas.
If you absolutley want minimal Hibernate overhead, you should try and execute your query with createSqlQuery, without specifying any Entities. If that is still slow, you will need to further tune your query or your database.
With Hibernate, I'd try the followings. First simply use setFirstResult() and setMaxResult() to limit the number of rows fetched, and see if that helps. Try and set the amount of rows returned to as low as 10 or 20. Out of memory error indicates you didn't limit the returned rows, so that's the first and most important thing.
If you don't need all those records in the cache, maybe you should turn off cache interaction for the query:
But then again, if you only get a few records at each interaction, cache handling shouldn't be much of an overhead, especially if you are likely to be able to use that data later.
If all that fails, maybe you could show us your generated query.