Meena, Hibernate "owns" the query cache, so Infinispan can't store more information than Hibernate wants to store.
On the other hand, Hibernate has another cache just for storing the actual data: the second level cache (which will also be using Infinispan). So if you would also store the object data in the query cache you would just waste memory by keeping the same data in two places.
Hibernate "owns" the query cache, so Infinispan can't store more information than Hibernate wants to store.
What if I want only Infinispan as a 2nd level cache and Hibernate just for OR mapping
In the documentation of Infinispan it says that there is query cache available in Infinispan. But I could not see any details if it is actually caching the objects or id's just as hibernate does?
I've tested Infinispan as my 2LC provider and it seems to behave pretty much like hibernate as far as what it stores and how it stores it in each region. If a query is marked as cacheable it will keep the SQL/HQL statement and the keys in the query cache. If you have entities marked as cacheable it will cache those and the query cache can make use of those entities if it needs to "rehydrate" an entry.
Ok, now I'm not sure I answered the right question... I thought you wanted to use Hibernate as a 2nd level/query cache implementation for Hibernate. In that case Hibernate controls what gets stored in the cache and you don't access Infinispan directly.
It looks instead like you are using the Infinispan query module, and I don't know too much about that module. But I don't think it does any query caching, although Lucene may do some caching under the hood.