This is how I did it: 1. Take your class the for which you want to create a proxy and create an interface with the same methods. class A { ... public fnctA(...) ... public fnctB(...) ... ... }
interface AProxy { public fnctA(...); public fnctB(...); ... } 2. Make the class for which you want to create the proxy implement the interface (this should require no coding changes to the original class (other than the implements) since the interface you created has exactly the same (public) methods). class A implements AProxy { ... } 3. When you get the resulting objects from a query involving this class, use the interface rather than the class. Query query = ... AProxy aProxy = (AProxy) broker.getObjectByQuery(query); Before calling any methods on aProxy, the object doesn't actually have any of your data in it: it simply contains information about *how* to get the data. The first time you call a method on aProxy, all of the data in the object is "materialized". OJB takes care of the materialization behind the scenes: that's why you have to create the interface. OJB can do what it has to (maintain a pointer to the data, materialize the first time a method is called, etc.) while at the same time giving you the "interface" you were expecting. Hope that helps Andrew P.S. I agree that the description of dynamic proxies in the documentation isn't very intuitive. -----Original Message----- From: Molitor, Stephen [mailto:[EMAIL PROTECTED]] Sent: Wednesday, November 20, 2002 11:45 AM To: 'OJB Users List' Subject: Reference Proxy interface I'm confused as to which interface reference proxies must implement. Tutorial 3 says: "Because a proxy reference is only about the location of the definition, the referenced class must implement a special interface." What is that 'special' interface? There's the VirtualProxy class, but that's a class, not an interface. Or, does it just mean that classes used as reference proxies must implement any old interface (i.e. Article implements InterfaceArticle) containing its persistent properties, like any other dynamic proxy? I'm hoping it's the latter, because I don't want to have to change my program code to configure when to use proxies; hopefully I can do all of that in the repository XML file. Thanks! Steve Molitor -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>