db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Armin Waibel <arm...@apache.org>
Subject Re: Referencing an abstract class. The next turn...
Date Wed, 13 Oct 2004 22:53:16 GMT
Hi Ludo,

I have problems to make the inheritance tests run with a patched version 
of OJB and the "extends"-attribute.
Seems I have problems with the mapping, but your examples do not use 
"extends" attribute
http://dev.factory-part.com/oss/ojb/samples/objects.html

How should the mapping look like when using patched "extends" version?
I try to run a modified version of InheritanceMultipleTableTest.java 
(this test originally use "super"-references to build the inheritance) 
from test suite with new mapping and the "extends"-attribute.

Employee<---Executive<---Manager using a compound PK (id Integer, id_2 
Long) and Company has a 1:n reference with Employee base class.

It seems that we will get the same problems as with "super"-references. 
If I store an Company object with an Manager object in Company's 
employees collection, the object was correctly stored.
But if I read the Company object from DB the employee collection only 
contains one object of type Employee instead of Manager - I'm wrong?

regards,
Armin


Ludovic Maitre (POP - Factory Part) wrote:

> Hello,
> 
> When you have this testcase or he have been put in cvs, i suppose that 
> our modified version of OJB (with the patch indicated at
> http://dev.factory-part.com/oss/ojb ) could pass it without problems.  
> We have designed our modifications to OJB source code for this purpose 
> (handling inhreitance over multiple tables, and returning the child 
> objects instances with child objects also populated with fields from 
> super class).
> I agree that our patches are not very nice and should be improved before 
> integration in ojb, but the ideas are here (and work in our context).
> So, if some of the experts of OJB could see if theses patchs solves this 
> issue, and especially if their is a way to introduce them in the source 
> base without breaking the other test cases, it will be nice.
> Have a good day,
> Ludo
> 
> Armin Waibel wrote:
> 
>>
>>
>> Carsten Spräner_Ext wrote:
>>
>>> Hi Armin,
>>>
>>> i looked at the test ojb....broker.InheritanceMultipleTableTest and 
>>> didn't
>>> find a place where you do a query to an Employee and than do a cast 
>>> to, for
>>> example, Manager. But that's exactly what i need. When mapping all 
>>> classes
>>> in one table this is possible. The test case should be:
>>>
>>>  1. query for all Employees where name like 'manager'. But create the 
>>> query
>>> with Employee.class.
>>>  2. assert that all loaded classes are instances of Manager.
>>>  3. assert that a attribute which is only in Manager is loaded.
>>>
>>> If this test case works it would be very nice.
>>>
>>
>> yep, this is the issue - OJB doesn't.
>> If you iterate and print the class types of the query result against 
>> Employee then you only get Employee types.
>>
>> Think this is a "bug" in consistence of inheritance behavior in OJB, 
>> because the other "inheritance mapping strategies" work different and 
>> will return the real classes not only base class instances.
>>
>> I will add a test to reproduce your problem.
>>
>> regards,
>> Armin
>>
>>> Best regards....
>>>
>>> carsten
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
> 
> 
> ---------------------------------------------------------------------
> 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


Mime
View raw message