You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Björn Voigt <bv...@hs-harz.de> on 2004/03/26 11:16:31 UTC
Problem with Mapping Inheritance Hierarchies
Hello OJB'lers,
I have a problem to map Inheritance Hierarchies, I'am the using the third
proposal of the tutoriala and mapping each class to a distinct table.
I have the following Classes:
1. A and B implements ABInterface
2. B extends A
public class A implements ABInterface{
int id;
int someValueFromA;
public String toString() {
return this.getClass() + " id:" +id +" a_value:" + someValueFromA;
}
}
public class B extends A {
int id;
int someValueFromB;
public String toString() {
return super.toString() + " b_value:" + someValueFromB;
}
}
My Mapping looks so:
<class-descriptor class="test.ABInterface">
<extent-class class-ref="test.A"/>
<extent-class class-ref="test.B"/>
</class-descriptor>
<class-descriptor class="test.A" table="a">
<field-descriptor name="id" column="id" jdbc-type="INTEGER"
primarykey="true" autoincrement="true" />
<field-descriptor name="someValueFromA" column="some_value_from_a"
jdbc-type="INTEGER" />
<extent-class class-ref="test.B"/>
</class-descriptor>
<class-descriptor class="test.B" table="b">
<field-descriptor name="id" column="a_id" jdbc-type="INTEGER"
primarykey="true" autoincrement="true" />
<field-descriptor name="someValueFromB" column="some_value_from_b"
jdbc-type="INTEGER" />
<reference-descriptor name="super" class-ref="test.A">
<foreignkey field-ref="id" />
</reference-descriptor>
</class-descriptor>
And the table looks:
CREATE TABLE A ( ID INT PRIMARY KEY, SOME_VALUE_FROM_A INT)
CREATE TABLE B ( A_ID INT NOT NULL, SOME_VALUE_FROM_B INT)
Table A contains to rows:
id | some_value_from_a
----+-------------------
1 | 1000
2 | 1000
Table B cointains a refenrence to the second row in B
a_id | some_value_from_b
------+-------------------
2 | 2000
Ok, what I want is to query the ABInterface and get two objects,
one instance of A and one of B (because id=2 and a_id=2) but what I get
is one
instance of A (OK thats right), but two instaces of B. And the b instances
cointains no value for the some_value_from_a field. A query have
following result:
[...]
Query q = QueryFactory.newQuery(ABInterface.class, c);
Iterator iter = broker.getCollectionByQuery(q).iterator();
while (iter.hasNext()) {
ABInterface element = (ABInterface) iter.next();
System.out.println(element.toString());
}
[...]
class test.B id:0 a_value:0 b_value:2000
class test.A id:1 a_value:1000
class test.B id:0 a_value:0 b_value:2000
What I want is:
class test.A id:1 a_value:1000
class test.B id:2 a_value:1000 b_value:2000
Could anyone tell what I do wrong or is it possible what want to do? ;-)
Thank you for help
Björn Voigt
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Still Probleml with Mapping Inheritance Hierarchies
Posted by Edson Carlos Ericksson Richter <ed...@mgrinformatica.com.br>.
I can reproduce this problem with OJB 1.0rc6.
Appear that when two or more tables with same PKs, with identical values
for their PKs have the following behaviour:
a) Get Identity for the first object. Get the object by Identity. Put it
in the ChainingIterator
b) Get Identity for second object. Since this identity is already
(remeber, the values of the PKs are the same), don't get the object
again. Just put it again.
c) and so on.
I don't know if this is the real steps done inside OJB (I tryied to
debug, but I must admit it's so much complex to me), but as far as I can
get debugged, is this that is occuring.
I think that the test should be made against the same PK and
getClass().getName(). If two are same, then the object is already inside
(and, if user asked for distinct, should not add repeated anyway).
Otherwise, should exect a getByIdentity using the correct table.
What do you think all?
Can someone test the extent tests using values in different tables with
same PK?
As workaround, I added ojbConcreteClass to my class-descriptor as PK,
and works fine (but I think it's a very, really bad solution).
Behaviour is same with or without proxies.
Best regards,
Edson Richter
Edson Carlos Ericksson Richter wrote:
> Hi!
>
> I don't know if this solves your problem, but AFAIK, you can't mix
> <field-descriptor> with <extent-class>, as you have done in
> class-descriptor for A class.
>
> More, I have no luck in using extent-class using a Interface as
> super-object. Have you tried an ABAbstractClass (I'm just trying a
> sidekick)?
>
> Best regards,
>
> Edson Richter
>
>
> Björn Voigt wrote:
>
>> OK, I have still no solution for my inheritance mapping problem.
>> There are my Classes A,B and C implementing the ABInterface, C and B
>> extend from A. I want to map each class to a distinct tables, but
>> on Multiple Joined Tables. The c an b table have its own primary
>> column "b_id" and "c_id" and both a foreign key "a_id" referenes the
>> a table.
>>
>> Table A: Table B:
>> id | some_value_from_a b_id | a_id | some_value_from_b
>> ----+------------------- ------+------+-------------------
>> 1 | 1000 100 | 1 | 1001
>> 2 | 2000
>>
>> Table C:
>> c_id | a_id | some_value_from_c
>> ------+------+-------------------
>> 101 | 2 | 2002
>>
>>
>>
>> Ok, if I query the ABInterface I want have two
>> instances, one of B and one of C, something like this:
>>
>> instance test.B id:1 a_value:1000 b_value:1001
>> instance test.C id:2 a_value:2000 c_value:2002
>>
>> But I get also instances of A, a query has this result:
>>
>> instance test.A id:1 a_value:1000
>> instance test.A id:2 a_value:2000
>> instance test.B id:1 a_value:1000 b_value:1001
>> instance test.C id:2 a_value:2000 c_value:2002
>>
>> But thats not all:
>>
>> instance into b values (1, 1, 1001); instead of:
>> instance into b values (100, 1, 1001);
>>
>> has the following query-result:
>>
>> instance test.A id:1 a_value:1000
>> instance test.A id:2 a_value:2000
>> instance test.A id:1 a_value:1000
>> instance test.C id:2 a_value:2000 c_value:2002
>>
>> if b_id equals to an id of the a-table, or b_id equals
>> to a c_id in c-table, the result is another.
>>
>> I am using rc5 and would be very happy, if you
>> can help me or give me an working example.
>>
>>
>> Björn Voigt
>>
>>
>> Here follows my complete source code:
>>
>> package test;
>> public class A implements ABInterface{
>> int id;
>> int someValueFromA;
>> public String toString() {
>> return this.getClass() + " id:" +id +" a_value:" +
>> someValueFromA;
>> }
>> }
>>
>> package test;
>> public class B extends A {
>> int b_id;
>> int someValueFromB;
>>
>> public String toString() {
>> return super.toString() + " b_value:" + someValueFromB;
>> }
>> }
>>
>> package test;
>> public class C extends A {
>> int c_id;
>> int someValueFromC;
>> public String toString() {
>> return super.toString() + " c_value:" + someValueFromC;
>> }
>> }
>>
>> <class-descriptor class="test.ABInterface">
>> <extent-class class-ref="test.A"/> <extent-class
>> class-ref="test.B"/>
>> <extent-class class-ref="test.C"/> </class-descriptor>
>>
>> <class-descriptor class="test.A" table="a">
>> <field-descriptor name="id" column="id" jdbc-type="INTEGER"
>> primarykey="true" autoincrement="true" />
>> <field-descriptor name="someValueFromA"
>> column="some_value_from_a" jdbc-type="INTEGER" />
>> <extent-class class-ref="test.B"/> <extent-class
>> class-ref="test.C"/>
>> </class-descriptor>
>>
>> <class-descriptor class="test.B" table="b">
>> <field-descriptor name="b_id" column="b_id" jdbc-type="INTEGER"
>> primarykey="true" autoincrement="true" />
>> <field-descriptor name="id" column="a_id" jdbc-type="INTEGER"/>
>> <field-descriptor name="someValueFromB"
>> column="some_value_from_b" jdbc-type="INTEGER"/>
>> <reference-descriptor name="super" class-ref="test.A">
>> <foreignkey field-ref="id"/>
>> </reference-descriptor>
>> </class-descriptor>
>>
>> <class-descriptor class="test.C" table="c">
>> <field-descriptor name="c_id" column="c_id" jdbc-type="INTEGER"
>> primarykey="true" autoincrement="true" />
>> <field-descriptor name="id" column="a_id" jdbc-type="INTEGER"/>
>> <field-descriptor name="someValueFromC" column="some_value_from_c"
>> jdbc-type="INTEGER"/>
>> <reference-descriptor name="super" class-ref="test.A">
>> <foreignkey field-ref="id"/>
>> </reference-descriptor>
>> </class-descriptor>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Still Probleml with Mapping Inheritance Hierarchies
Posted by Edson Carlos Ericksson Richter <ed...@mgrinformatica.com.br>.
Hi!
I don't know if this solves your problem, but AFAIK, you can't mix
<field-descriptor> with <extent-class>, as you have done in
class-descriptor for A class.
More, I have no luck in using extent-class using a Interface as
super-object. Have you tried an ABAbstractClass (I'm just trying a
sidekick)?
Best regards,
Edson Richter
Björn Voigt wrote:
> OK, I have still no solution for my inheritance mapping problem.
> There are my Classes A,B and C implementing the ABInterface, C and B
> extend from A. I want to map each class to a distinct tables, but
> on Multiple Joined Tables. The c an b table have its own primary
> column "b_id" and "c_id" and both a foreign key "a_id" referenes the a
> table.
>
> Table A: Table B:
> id | some_value_from_a b_id | a_id | some_value_from_b
> ----+------------------- ------+------+-------------------
> 1 | 1000 100 | 1 | 1001
> 2 | 2000
>
> Table C:
> c_id | a_id | some_value_from_c
> ------+------+-------------------
> 101 | 2 | 2002
>
>
>
> Ok, if I query the ABInterface I want have two
> instances, one of B and one of C, something like this:
>
> instance test.B id:1 a_value:1000 b_value:1001
> instance test.C id:2 a_value:2000 c_value:2002
>
> But I get also instances of A, a query has this result:
>
> instance test.A id:1 a_value:1000
> instance test.A id:2 a_value:2000
> instance test.B id:1 a_value:1000 b_value:1001
> instance test.C id:2 a_value:2000 c_value:2002
>
> But thats not all:
>
> instance into b values (1, 1, 1001); instead of:
> instance into b values (100, 1, 1001);
>
> has the following query-result:
>
> instance test.A id:1 a_value:1000
> instance test.A id:2 a_value:2000
> instance test.A id:1 a_value:1000
> instance test.C id:2 a_value:2000 c_value:2002
>
> if b_id equals to an id of the a-table, or b_id equals
> to a c_id in c-table, the result is another.
>
> I am using rc5 and would be very happy, if you
> can help me or give me an working example.
>
>
> Björn Voigt
>
>
> Here follows my complete source code:
>
> package test;
> public class A implements ABInterface{
> int id;
> int someValueFromA;
> public String toString() {
> return this.getClass() + " id:" +id +" a_value:" +
> someValueFromA;
> }
> }
>
> package test;
> public class B extends A {
> int b_id;
> int someValueFromB;
>
> public String toString() {
> return super.toString() + " b_value:" + someValueFromB;
> }
> }
>
> package test;
> public class C extends A {
> int c_id;
> int someValueFromC;
> public String toString() {
> return super.toString() + " c_value:" + someValueFromC;
> }
> }
>
> <class-descriptor class="test.ABInterface">
> <extent-class class-ref="test.A"/>
> <extent-class class-ref="test.B"/>
> <extent-class class-ref="test.C"/>
> </class-descriptor>
>
> <class-descriptor class="test.A" table="a">
> <field-descriptor name="id" column="id" jdbc-type="INTEGER"
> primarykey="true" autoincrement="true" />
> <field-descriptor name="someValueFromA"
> column="some_value_from_a"
> jdbc-type="INTEGER" />
> <extent-class class-ref="test.B"/>
> <extent-class class-ref="test.C"/>
> </class-descriptor>
>
> <class-descriptor class="test.B" table="b">
> <field-descriptor name="b_id" column="b_id" jdbc-type="INTEGER"
> primarykey="true" autoincrement="true" />
> <field-descriptor name="id" column="a_id" jdbc-type="INTEGER"/>
> <field-descriptor name="someValueFromB" column="some_value_from_b"
> jdbc-type="INTEGER"/>
> <reference-descriptor name="super" class-ref="test.A">
> <foreignkey field-ref="id"/>
> </reference-descriptor>
> </class-descriptor>
>
> <class-descriptor class="test.C" table="c">
> <field-descriptor name="c_id" column="c_id" jdbc-type="INTEGER"
> primarykey="true" autoincrement="true" />
> <field-descriptor name="id" column="a_id" jdbc-type="INTEGER"/>
> <field-descriptor name="someValueFromC" column="some_value_from_c"
> jdbc-type="INTEGER"/>
> <reference-descriptor name="super" class-ref="test.A">
> <foreignkey field-ref="id"/>
> </reference-descriptor>
> </class-descriptor>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Still Probleml with Mapping Inheritance Hierarchies
Posted by Björn Voigt <bv...@hs-harz.de>.
OK, I have still no solution for my inheritance mapping problem.
There are my Classes A,B and C implementing the ABInterface, C and B
extend from A. I want to map each class to a distinct tables, but
on Multiple Joined Tables. The c an b table have its own primary column
"b_id" and "c_id" and both a foreign key "a_id" referenes the a table.
Table A: Table B:
id | some_value_from_a b_id | a_id | some_value_from_b
----+------------------- ------+------+-------------------
1 | 1000 100 | 1 | 1001
2 | 2000
Table C:
c_id | a_id | some_value_from_c
------+------+-------------------
101 | 2 | 2002
Ok, if I query the ABInterface I want have two
instances, one of B and one of C, something like this:
instance test.B id:1 a_value:1000 b_value:1001
instance test.C id:2 a_value:2000 c_value:2002
But I get also instances of A, a query has this result:
instance test.A id:1 a_value:1000
instance test.A id:2 a_value:2000
instance test.B id:1 a_value:1000 b_value:1001
instance test.C id:2 a_value:2000 c_value:2002
But thats not all:
instance into b values (1, 1, 1001); instead of:
instance into b values (100, 1, 1001);
has the following query-result:
instance test.A id:1 a_value:1000
instance test.A id:2 a_value:2000
instance test.A id:1 a_value:1000
instance test.C id:2 a_value:2000 c_value:2002
if b_id equals to an id of the a-table, or b_id equals
to a c_id in c-table, the result is another.
I am using rc5 and would be very happy, if you
can help me or give me an working example.
Björn Voigt
Here follows my complete source code:
package test;
public class A implements ABInterface{
int id;
int someValueFromA;
public String toString() {
return this.getClass() + " id:" +id +" a_value:" +
someValueFromA;
}
}
package test;
public class B extends A {
int b_id;
int someValueFromB;
public String toString() {
return super.toString() + " b_value:" + someValueFromB;
}
}
package test;
public class C extends A {
int c_id;
int someValueFromC;
public String toString() {
return super.toString() + " c_value:" + someValueFromC;
}
}
<class-descriptor class="test.ABInterface">
<extent-class class-ref="test.A"/>
<extent-class class-ref="test.B"/>
<extent-class class-ref="test.C"/>
</class-descriptor>
<class-descriptor class="test.A" table="a">
<field-descriptor name="id" column="id" jdbc-type="INTEGER"
primarykey="true" autoincrement="true" />
<field-descriptor name="someValueFromA" column="some_value_from_a"
jdbc-type="INTEGER" />
<extent-class class-ref="test.B"/>
<extent-class class-ref="test.C"/>
</class-descriptor>
<class-descriptor class="test.B" table="b">
<field-descriptor name="b_id" column="b_id" jdbc-type="INTEGER"
primarykey="true" autoincrement="true" />
<field-descriptor name="id" column="a_id" jdbc-type="INTEGER"/>
<field-descriptor name="someValueFromB" column="some_value_from_b"
jdbc-type="INTEGER"/>
<reference-descriptor name="super" class-ref="test.A">
<foreignkey field-ref="id"/>
</reference-descriptor>
</class-descriptor>
<class-descriptor class="test.C" table="c">
<field-descriptor name="c_id" column="c_id" jdbc-type="INTEGER"
primarykey="true" autoincrement="true" />
<field-descriptor name="id" column="a_id" jdbc-type="INTEGER"/>
<field-descriptor name="someValueFromC" column="some_value_from_c"
jdbc-type="INTEGER"/>
<reference-descriptor name="super" class-ref="test.A">
<foreignkey field-ref="id"/>
</reference-descriptor>
</class-descriptor>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Problem with Mapping Inheritance Hierarchies
Posted by Björn Voigt <bv...@hs-harz.de>.
Hello again,
I have still problems with mapping inheritance hierarchies.
I solved my first problem with nonfilled extend fields in the
subclass, but I still recieve two instances of one row.
My tables contains the following rows
select * from a;
id | some_value_from_a
----+-------------------
1 | 1000
2 | 1000
select * from b;
id | a_id | some_value_from_b
----+------+-------------------
1 | 2 | 2000
A query has the this result ( there are two instances of B for one Row)
class test.B id:2 a_value:1000 b_value:2000
class test.B id:2 a_value:1000 b_value:2000
class test.A id:2 a_value:1000
Björn Voigt schrieb:
> Hello OJB'lers,
>
> I have a problem to map Inheritance Hierarchies, I'am the using the third
> proposal of the tutoriala and mapping each class to a distinct table.
>
> I have the following Classes:
>
> 1. A and B implements ABInterface
> 2. B extends A
>
> public class A implements ABInterface{
> int id;
> int someValueFromA;
>
> public String toString() {
> return this.getClass() + " id:" +id +" a_value:" + someValueFromA;
> }
> }
>
> public class B extends A {
> int id;
> int someValueFromB;
>
> public String toString() {
> return super.toString() + " b_value:" + someValueFromB;
> }
> }
>
> My Mapping looks so:
>
> <class-descriptor class="test.ABInterface">
> <extent-class class-ref="test.A"/>
> <extent-class class-ref="test.B"/>
> </class-descriptor>
>
> <class-descriptor class="test.A" table="a">
> <field-descriptor name="id" column="id" jdbc-type="INTEGER"
> primarykey="true" autoincrement="true" />
> <field-descriptor name="someValueFromA" column="some_value_from_a"
> jdbc-type="INTEGER" />
> <extent-class class-ref="test.B"/>
> </class-descriptor>
>
> <class-descriptor class="test.B" table="b">
> <field-descriptor name="id" column="a_id" jdbc-type="INTEGER"
> primarykey="true" autoincrement="true" />
> <field-descriptor name="someValueFromB" column="some_value_from_b"
> jdbc-type="INTEGER" />
> <reference-descriptor name="super" class-ref="test.A">
> <foreignkey field-ref="id" />
> </reference-descriptor>
> </class-descriptor>
>
> And the table looks:
>
> CREATE TABLE A ( ID INT PRIMARY KEY, SOME_VALUE_FROM_A INT)
> CREATE TABLE B ( A_ID INT NOT NULL, SOME_VALUE_FROM_B INT)
>
> Table A contains to rows:
>
> id | some_value_from_a
> ----+-------------------
> 1 | 1000
> 2 | 1000
>
> Table B cointains a refenrence to the second row in B
>
> a_id | some_value_from_b
> ------+-------------------
> 2 | 2000
>
>
> Ok, what I want is to query the ABInterface and get two objects,
> one instance of A and one of B (because id=2 and a_id=2) but what I get
> is one
> instance of A (OK thats right), but two instaces of B. And the b instances
> cointains no value for the some_value_from_a field. A query have
> following result:
>
> [...]
>
> Query q = QueryFactory.newQuery(ABInterface.class, c);
> Iterator iter = broker.getCollectionByQuery(q).iterator();
> while (iter.hasNext()) {
> ABInterface element = (ABInterface) iter.next();
> System.out.println(element.toString());
> }
>
> [...]
>
> class test.B id:0 a_value:0 b_value:2000
> class test.A id:1 a_value:1000
> class test.B id:0 a_value:0 b_value:2000
>
> What I want is:
> class test.A id:1 a_value:1000
> class test.B id:2 a_value:1000 b_value:2000
>
> Could anyone tell what I do wrong or is it possible what want to do? ;-)
>
> Thank you for help
>
> Björn Voigt
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Problem with Mapping Inheritance Hierarchies
Posted by Björn Voigt <bv...@hs-harz.de>.
hello again,
I have still problems with the Mapping of Hierarchies Inheritance,
I solved the problem with the non-filled extended fields, but I get
still two instances of one row:
class test.B id:2 a_value:1000 b_value:2000
class test.B id:2 a_value:1000 b_value:2000
class test.A id:2 a_value:1000
table a
id | some_value_from_a
----+-------------------
1 | 1000
2 | 1000
table b
id | a_id | some_value_from_b
----+------+-------------------
1 | 2 | 2000
the mapping looks:
<class-descriptor class="test.A" table="a">
<field-descriptor name="id" column="id" jdbc-type="INTEGER"
primarykey="true" autoincrement="true" />
<field-descriptor name="someValueFromA" column="some_value_from_a"
jdbc-type="INTEGER" />
<extent-class class-ref="test.B"/>
</class-descriptor>
<class-descriptor class="test.B" table="b">
<field-descriptor name="b_id" column="id" jdbc-type="INTEGER"
primarykey="true" autoincrement="true" />
<field-descriptor name="id" column="a_id" jdbc-type="INTEGER"/>
<field-descriptor name="someValueFromB" column="some_value_from_b"
jdbc-type="INTEGER" />
<reference-descriptor name="super" class-ref="test.A"
auto-retrieve="true"
auto-update="true"
auto-delete="true"
>
<foreignkey field-ref="id" />
</reference-descriptor>
</class-descriptor>
Björn Voigt schrieb:
> Hello OJB'lers,
>
> I have a problem to map Inheritance Hierarchies, I'am the using the third
> proposal of the tutoriala and mapping each class to a distinct table.
>
> I have the following Classes:
>
> 1. A and B implements ABInterface
> 2. B extends A
>
> public class A implements ABInterface{
> int id;
> int someValueFromA;
>
> public String toString() {
> return this.getClass() + " id:" +id +" a_value:" + someValueFromA;
> }
> }
>
> public class B extends A {
> int id;
> int someValueFromB;
>
> public String toString() {
> return super.toString() + " b_value:" + someValueFromB;
> }
> }
>
> My Mapping looks so:
>
> <class-descriptor class="test.ABInterface">
> <extent-class class-ref="test.A"/>
> <extent-class class-ref="test.B"/>
> </class-descriptor>
>
> <class-descriptor class="test.A" table="a">
> <field-descriptor name="id" column="id" jdbc-type="INTEGER"
> primarykey="true" autoincrement="true" />
> <field-descriptor name="someValueFromA" column="some_value_from_a"
> jdbc-type="INTEGER" />
> <extent-class class-ref="test.B"/>
> </class-descriptor>
>
> <class-descriptor class="test.B" table="b">
> <field-descriptor name="id" column="a_id" jdbc-type="INTEGER"
> primarykey="true" autoincrement="true" />
> <field-descriptor name="someValueFromB" column="some_value_from_b"
> jdbc-type="INTEGER" />
> <reference-descriptor name="super" class-ref="test.A">
> <foreignkey field-ref="id" />
> </reference-descriptor>
> </class-descriptor>
>
> And the table looks:
>
> CREATE TABLE A ( ID INT PRIMARY KEY, SOME_VALUE_FROM_A INT)
> CREATE TABLE B ( A_ID INT NOT NULL, SOME_VALUE_FROM_B INT)
>
> Table A contains to rows:
>
> id | some_value_from_a
> ----+-------------------
> 1 | 1000
> 2 | 1000
>
> Table B cointains a refenrence to the second row in B
>
> a_id | some_value_from_b
> ------+-------------------
> 2 | 2000
>
>
> Ok, what I want is to query the ABInterface and get two objects,
> one instance of A and one of B (because id=2 and a_id=2) but what I get
> is one
> instance of A (OK thats right), but two instaces of B. And the b instances
> cointains no value for the some_value_from_a field. A query have
> following result:
>
> [...]
>
> Query q = QueryFactory.newQuery(ABInterface.class, c);
> Iterator iter = broker.getCollectionByQuery(q).iterator();
> while (iter.hasNext()) {
> ABInterface element = (ABInterface) iter.next();
> System.out.println(element.toString());
> }
>
> [...]
>
> class test.B id:0 a_value:0 b_value:2000
> class test.A id:1 a_value:1000
> class test.B id:0 a_value:0 b_value:2000
>
> What I want is:
> class test.A id:1 a_value:1000
> class test.B id:2 a_value:1000 b_value:2000
>
> Could anyone tell what I do wrong or is it possible what want to do? ;-)
>
> Thank you for help
>
> Björn Voigt
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org