Session.get() in combination whith cache and lazy="false" broken???
I have trouble with Session.get() which is supposed to always return a non-proxied instance. Well it does not. Not even when using lazy="true". I also have caching enabled for the class. I have narrowed it down to the class org.hibernate.event.def.DefaultLoadEventListener
in the method proxyOrLoad (at around row number 227)
I actualy get a proxy back even though I have no proxies enabled. I might add that it works when the cache does not contain a value.
Is this as expected? Why does the cache usage change the behaviour?
Keep up the good work!
/Konstantin
Code:
org.hibernate.event.def.DefaultLoadEventListenerin.proxyOrLoad (at around row number 227)
Object proxy = persistenceContext.getProxy(keyToLoad);
if ( proxy != null ) { // <-- Execution enters this part /Konstantin
log.trace("entity proxy found in session cache");
Object impl;
if ( options.isAllowProxyCreation() ) {
impl = null;
}
else {
//force initialization of the proxy
impl = ( (HibernateProxy) proxy ).getHibernateLazyInitializer().getImplementation();
}
// return existing or narrowed proxy
Object narrowed = persistenceContext.narrowProxy( proxy, persister, keyToLoad, impl );
return narrowed;
}
else if ( options.isAllowProxyCreation() ) {
log.trace("creating new proxy for entity");
// return new uninitialized proxy
proxy = persister.createProxy( event.getEntityId(), event.getSession() );
persistenceContext.getBatchFetchQueue().addBatchLoadableEntityKey(keyToLoad);
persistenceContext.addProxy(keyToLoad, proxy);
return proxy;
}
mapping excrept:
<class name="CompositeElement" table="CMT_PROD_PAGE_ELEMENT"
lazy="false"
>
<cache usage="nonstrict-read-write" />
...
Hibernate version:3.01