Hi,
when loading entities from query results the following method is called in hibernate source (org.hibernate.loader.Loader:1341)
Code:
//If the object is already loaded, return the loaded one
object = session.getEntityUsingInterceptor( key );
This call attempts to find the entity in current session. If the session does not contain the entity the loader will continue loading results from database.
I wonder where second level cache is used?
Why is it not possible to get entities from second level cache?
Perhaps I'missing an important step?
Assuming that the second level cache is not called I succeeded in lookup the entity from second level cache manually using a SessionInterceptor
Code:
public Object getEntity(String entityName, Serializable id) {
...
return loadFromSecondLevelCache(event, persister, loadType);
}
Are there any disadvantages from this approach?
Hibernate version 3.6.7
Thanks,
Alex