The simplest way to handle this now in the current OJB framework is to capture the writeObject() serialization method, and then do your determination if you want to replace your proxies out for real objects.
For example, we do this as well to serialize out full graphs that are in HttpSession. Our base object has implemented the writeObject() method: private void writeObject(ObjectOutputStream out) throws IOException { ProxyUtil.backfillProixes(this); out.defaultWriteObject(); } Our helper method does the following: public static void backfillProixes(BusinessObjectProxyInterface bizObj) { Class cls = bizObj.getClass(); while (!cls.getName().equals(Object.class.getName())) { // Need to backfill in all real objects as opposed to proxies. try { Field[] fields = cls.getDeclaredFields(); for (int i = 0; i < fields.length; i++) { Field field = fields[i]; field.setAccessible(true); if (BusinessObjectProxyInterface.class.isAssignableFrom(field.getType())) { Object object = field.get(bizObj); if (object instanceof Proxy) { PersistenceServicableIndirectionHandler ih = (PersistenceServicableIndirectionHandler)Proxy.getInvocationHandler(obje ct); field.set(bizObj, ih.getRealSubject()); } } } cls = cls.getSuperclass(); } catch (SecurityException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } } } In this case BusinessObjectProxyInterface is a base interface class that all of our Proxy interfaces extend from. You will want to customize it you're your own use. Hope this helps. -Andrew > -----Original Message----- > From: Kirill Petrov [mailto:[EMAIL PROTECTED] > Sent: Tuesday, April 12, 2005 1:50 AM > To: ojb-user@db.apache.org > Subject: partial materialization?.. > > Hello everybody, > > I have a database that has very complex objects called > Models. From time to time I need to present the user only > with the names of those models. > Since I don't want to instantiate every model only for that, > I used dynamic proxies for all the classes that comprise a > particular Model object. > > However, sometimes, I need to intantiate a whole model, > serialize it and send it through the web service. In this > case, if I just get a model from the database and send it > over the wire, I end up sending a bunch of proxy objects > instead of a real model. > > What's the right solution for this problem? > > Kirill > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]