db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Taal <mt...@springsite.com>
Subject ojb 1.1: Discriminator-descriptor issue
Date Tue, 19 Apr 2005 16:53:53 GMT
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>

-- 

With Regards, Martin Taal

Springsite
Barchman Wuytierslaan 72b
3818 LK Amersfoort
tel: +31 (0)33 462 02 07
fax: +31 (0)33 463 77 12
Mobile: +31 (0)6 288 48 943
email: mtaal@springsite.com
web: www.springsite.com


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


Mime
View raw message