JPA/HIBERNATE - Are objects instances cached indexed just by id?

Yes, the second level cache works for query that looks for a single object based on Id i.e. When using EntityManager.find() or EntityManager.getReference() (or the equivalent Session#get() and Session#load() from the AFAIK, this applies to all JPA implementations.

Yes, the second level cache works for query that looks for a single object based on Id i.e. When using EntityManager.find() or EntityManager.getReference() (or the equivalent Session#get() and Session#load() from the AFAIK, this applies to all JPA implementations.Is there any way to get it working without need to activate the query cache? With standard JPA, I don't see any other option than using the Query Cache.

But if you don't mind using there might be an alternative with Query#iterate(). With Query#iterate(), bernate will issue a SQL query that will fetch only the IDs and when you iterate over the results, it will load the corresponding entities from the cache. Obviously, Query#iterate() will be much slower than Query#list() if you're not using a second level cache.

Personally, I'd use the query cache. See also bernate: Truly Understanding the Second-Level and Query Caches.

Many thanks ... – Thiago Oct 25 '10 at 14:17 @user430830: You're welcome. – Pascal Thivent Oct 25 '10 at 14:34.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions