Sorry by reposting, but appear that my last post wasn't to the list... -----------------------
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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
