I'm experimenting with using AOP techniques (ala Spring) to handle transaction demarcation declaratively. As part of my experimentation, I thought it would be neat if I could have detatched business objects reassociate themselves with a currently existing session automatically when they're used.
I created a simple interceptor class which intercepts calls to my DAO objects and proxies any returned business objects. The proxy objects can then reassociate their target business objects with a currently existing session when appropriate. This works fine.
Once a business object is proxied, any associated business objects which it returns should also be proxied. Here's where I run into trouble. I need to be able to swap the objects in a PersistantCollection with proxied versions of themselves without setting the dirty flag on the collection. I can't find a way to do this.
Can anyone think of a not-too-complicated way to do what I'd like to do? The API says that PersistantCollection objects are treated as value objects, so *theoretically* could I instantiate a brand new one (provided I instantiate the correct subclass)? What pitfalls would that include?
_________________ - Matt
|