Hi, all
Is it some how possible to "intercept" loaded objects and replace lazy ends from 2-level cache. I have some heavy used domain entities that all are target of the 2-level cache. Instead of making associations to these entities eagerly fetched from referencing parent (through configuration) I would rather wish somehow to intercept loading of these parent objects and replace lazy proxies with ones obtained from 2-level cache (because eager fetching through configutation will result in actual sql executed towards to the DB (always JOIN entities that are already stored in 2-level cache) as well increased io between DB and AppServer - so this is last option I would use).
I tried to use Interceptor.onLoad by checking loaded state properties of given type from state array and was trying to initialize them from cache (session.get(class, id) that should first check sessionfac. level (2-level) cache) but this does not work - objects will remain proxies. And as I understand, it should not work because Interceptor contract very clearly states:
* The <tt>Session</tt> may not be invoked from a callback (nor may a callback cause a collection or proxy to * be lazily initialized).<br>
But accessing 2-level cache is not possible without using session (as far as I know).
Does anybody know some alternative that will make me happy ;)?
Thank you! Ilhan
|