db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jakob Braeuchi <jbraeu...@gmx.ch>
Subject Re: ojb 1.1: Discriminator-descriptor issue
Date Fri, 29 Apr 2005 20:12:40 GMT
hi martin,

i think you are mixing different mapping strategies. if class is mapped 
to multiple joined tables why do you then store multiple classes in the 
same table (that's what the discriminator is for) ?


Martin Taal schrieb:
> Hi Jakob,
> The discriminator value is correct in case the classes are mapped to 
> separate tables. Also in the case that the hierarchy is stored in one 
> table then it works correctly. So only in case of the joined table it 
> goes wrong.
> I can see in the ojb source code that it uses the value specified in the 
> discriminator (or its classdescriptor) to put in the classname column 
> (while it should use the class of the live object). It is strange that 
> in the case everything is stored in one table that it then works correctly.
> Btw I am looking and testing against the 1.1 cvs branche.
> I gues that solving this could also help the query issue just reported 
> by other also (and mentioned in your release notes as noted in the 
> mailing list :-).
> gr. Martin
> Jakob Braeuchi wrote:
>> hi martin,
>> is the discriminator also wrong when the classes are mapped to 
>> separate tables ?
>> ojb has some issues with multi-mapped tables and armin is working on a 
>> testcase.
>> jakob
>> Martin Taal schrieb:
>>> Hi,
>>> When I have a class hierarchy mapped to multiple (joined) tables then I
>>> am not sure how to use the discriminator-descriptor. At least in the way
>>> I try it it doesn't work.
>>> An example I have a class A and its subclass B.
>>> A is stored in table A and the subclass part of B is stored in table 
>>> B. So get B a join has to be made between tables A and B.
>>> In A I have a discriminator field (specified in the 
>>> discriminator-descriptor).
>>> I store one A and one B object creating two records in the A table 
>>> and one in the B table. This is correct. The discriminator field in 
>>> the A table however only contains the classname of A (for both 
>>> records). This I think is not correct, for the B record it should 
>>> contain the classname of B.
>>> Also when I then retrieve all A objects I get two objects both of 
>>> type A while one of the A object should actually be an instance of B.
>>> Btw, in the case that I store the classhierarchy in one table then 
>>> the above works fine.
>>> As I am looking at the 1.1 branche I am not sure if this part is yet 
>>> completely finished?
>>> Maybe also my setup maybe wrong, see the repository.xml here:
>>> <!-- class: org.elver.store.test.testcasesimple2.A in table: A -->
>>> <class-descriptor class="org.elver.store.test.testcasesimple2.A" 
>>> table="A">
>>>     <discriminator-descriptor column="A_classname" 
>>> jdbc-type="VARCHAR" value="org.elver.store.test.testcasesimple2.A"/>
>>>     <field-descriptor  name="name" column="name" jdbc-type="VARCHAR" 
>>> nullable="true"/>
>>>     <field-descriptor  name="ID" column="ID" jdbc-type="INTEGER" 
>>> primarykey="true" autoincrement="true" access="anonymous"/>
>>> </class-descriptor>
>>> <!-- class: org.elver.store.test.testcasesimple2.B in table: B -->
>>> <class-descriptor class="org.elver.store.test.testcasesimple2.B" 
>>> table="B">
>>>     <discriminator-descriptor column="B_classname" 
>>> jdbc-type="VARCHAR" value="org.elver.store.test.testcasesimple2.B"/>
>>>     <field-descriptor  name="nameb" column="nameb" 
>>> jdbc-type="VARCHAR" nullable="true"/>
>>>     <field-descriptor  name="A_ID" column="A_ID" jdbc-type="INTEGER" 
>>> primarykey="true" access="anonymous"/>
>>>     <reference-descriptor name="super" 
>>> class-ref="org.elver.store.test.testcasesimple2.A" 
>>> auto-retrieve="true" auto-update="true" auto-delete="true">
>>>         <foreignkey field-ref="A_ID" />
>>>     </reference-descriptor>
>>> </class-descriptor>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-dev-help@db.apache.org

To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org

View raw message