Monday, May 19, 2008

Remote lazy loading in client server environments

I made some steps yesterday with hibernate in regards to realizing a remote lazy loading feature. I read Gavin Kings opinion on that in a forum entries, he arguments that remote lazy loading is a no go as it breaks transaction isolation. I came across h3t which uses jboss-aop and that comes which a javaagent thats not useful in the osgi environment (or does anyone know to make it). So I started off on my own and try to adopt an old example from the hibernate site. So far so good, the example expects that the remote call has access to the former calls session. Another no go. I dived into the hibernate code and all I found is that lazy loading is so tightly coupled to the hibernate session that theres no chance to make it in a day. I thought of Gavin's arguments and I cant see the point. In my environment there is no transaction cotext at all. I retrieve objects from the server side, mainpulate them and sen them back. Inbetween theres not a glimpse of a transaction, so I do not see why it shouldnt be allowed to split ob the fetch aka lazy load the object graph when desirable. Theres many situations and many people out there that broke their head upon that. Maybe I should head on to Eike Steppers CDO anyway.


Tom said...

Exactly because if this we are using iBatis because behaves exactly like you want it too. There's no transaction-context within lazy-loading. The drawback is that you need to write your SQL-statements by hand (something I always preferred any way). We have integrated this nicely into a EMF-Model.

Rob said...

Thomas: Sorry H3T didn't work for you. Is there any way you could be persuaded to write up an enhancement request here?

ekke said...

perhaps you should have a look at Eclipse Riena: they have remote osgi services, object transactions and are working on persistence with hibernate.

Tom said...

ekke but as far as I know they also don't have a strategy to address the lazy loading problem.

Last time I talked to Christian Campo he said that their business logic on the server takes care that no lazy loading is happening by nulling certain parts of their model.

littlejohn said...

take a look at the following library:

If you use spring in your app, then using this lib should be straightforward. Otherwise take a look at the code and at the tests.


Using Mapstruct with Protobuf3