[OJB-developers] mapping abstract classes ?
Brought to you by:
thma
From: Jakob B. <jbr...@gm...> - 2002-06-25 05:59:26
|
hi, i have a question regarding the mapping of abstract classes. given the following class hierarchy: Project ..ITProject (abstract) ....SoftwareProject ....HardwareProject using the tables PROJECT, SW_PROJECT, HW_PROJECT. i can use the following mapping:=20 <class-descriptor class=3D"org.apache.ojb.broker.Project" table=3D"PROJECT" > <extent-class class-ref=3D"org.apache.ojb.broker.SoftwareProject" = /> <extent-class class-ref=3D"org.apache.ojb.broker.HardwareProject" = /> ... and class-descriptors for SoftwareProject and HardwareProject. if i want to query ITProjects i'll have to define a class-descriptor: <class-descriptor class=3D"org.apache.ojb.broker.ITProject" > <extent-class class-ref=3D"org.apache.ojb.broker.SoftwareProject" = /> <extent-class class-ref=3D"org.apache.ojb.broker.HardwareProject" = /> </class-descriptor> this all works fine. what irritates me is the duplicate definition of = extents.=20 so i tried the following mapping, which reflects the class hierarchy: <class-descriptor class=3D"org.apache.ojb.broker.Project" table=3D"PROJECT" > <extent-class class-ref=3D"org.apache.ojb.broker.ITProject" /> ... <class-descriptor class=3D"org.apache.ojb.broker.ITProject" > <extent-class class-ref=3D"org.apache.ojb.broker.SoftwareProject" = /> <extent-class class-ref=3D"org.apache.ojb.broker.HardwareProject" = /> </class-descriptor> this mapping fails because ITProject has no table :( so i came up with the following:=20 if the extent-class references an 'abstract' class (one without table), = the search should continue with the extents-classes of the 'abstract' = class. the only drawback i see so far is performance caused by checking all = extent-classes. what do think of it ? jakob |