Hi, I'm implementing an SQLObject layer over a legacy database and have come accross an interesting problem.
I have a table of Object types. Such that each row in the table corresponds to an other table in the database and in effeect also correpsongs to a Class. There are many places in the database which then use two fields to deterimin the correct linkage. The first column gives a reference to the Object table, http://www.asiatravel.com/asbcondotels/princeplaza/index.html Effectilby giving the Class of the object pointed to. The 2nd colum,n is the foreign key value which needs to be looked up on the apropriate table. I would like to hide this behaviour as much as possible. One approach, which I believe might work is something like inheritence, but where all the classes in a given hiarchy use the same table, and the actual class returned is based on the Object Type, The idea being that each version would need a different definition of the foreign Key column. A 2nd Item which I would find usefull is delegation. That is exposing properties on one object which are actually implemented on another and linked by a foreign Key. I have already done something like this manually. I have a document object and a diocument_version object. Now each document has a current version and 99% of the time user is only interested in the current version, os I have a set of stub methods of the form def _get_x(self): return self.property._get_x() def _set_x(selof, value): self.property._set_x(self, value) It would be hacny to be able to pass an exposes argument to a foreign key column, which lists the names of methods that should be delegated in the above fasion. The same could apply to SingleJoin instances. I would be using both of these stratages in tandum. As follows 1) Documents records in my database can ahve an owner/ (there is a seperate document owner table as a doucment can be linked to mulitple owners)., which can be a Person or a Company. So I need to selectilvy link to either the companies table or the Person table. At the same time, most of the time I am only interested in a few details of the Person/Company such as their name, Phone Number email etc. so most of the time I will want to behave as if the DocumentOwner had a name Phone email etc, without explicitly traversing the join (I know that SQL object will still do so in the back ground). Needless to say I will be digging in the implementation of IheritableSQlObject, but if Any one has any ideas on how this could be implemented (or what methods I need to hook into, I would be most greatful. If you have encountered similer problems berfore or can suggest an alternative approach that would be great as well. ------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642 _______________________________________________ sqlobject-discuss mailing list sqlobject-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss