From: Chris N. <ch...@si...> - 2002-11-07 00:07:10
|
On Thu, Nov 07, 2002 at 01:04:04AM +1100, Gavin King wrote: > I think its better to do this kind of thing by subclassing EntityPersister > and overriding instantiate(). However, that will not work properly in the > current implentation (for example getPersister( object.getClass() ) would > fail). Would you please investigate what kind of changes would be required > to make this approach work? In a nutshell, if goal is to allow instantiate to return any object as a substitute for the original object, then Hibernate needs a way to take that object and map back to the original object. I was toying around with requiring the substituted object to implement a special interface: public interface UserProxy { public Object getProxiedObject(); } Hibernate would dereference incoming objects that implemented the interface. For performance, maybe it would only do this after determining that it couldn't work with original object. But this doesn't handle things like SessionFactory.getClassMetadata, which takes a Class. Which leads me to believe that maybe it is better to keep this all out of Hibernate and just say that it's up to the application to wrap the Session, SessionFactory, and other public interfaces appropriately. -Chris |