in a DB2 databse
Table A has a PK named id that is also an identity (autoincriment) column
Table B has a PK called id that is also a FK to table A's id field
When attempting to insert Class A, which contains an instance of Class B, it seems that OJB attempts to insert class B before class A.
right, this is current behavior.
This fails, as class A doesn't have a proper PK yet, and thus class B doesn't have a valid PK yet.
Workaround for PB-api could be, first do PB.store(A) (without referenced object), then set PK from in reference B and do PB.store(B) or set reference in A and store A again.
given that I can't change my poorly designed database, is there anything I can do within OJB to get around this problem?
Do I simply need to manually insert class A and B?
Of course you can use OJB, but you have to prepare the B objects before insert (update, delete will work). Currently OJB isn't smart enough to handle this automatic. But it shouldn't be a problem to enhance OJB to support this.
That would be a shame, as the auto-update feature works great for instances of class A and B that already exist.
any suggestions would be appriciated.
Please make a feature request. I think you are right, OJB should be able handle this, e.g. by introduce a setting in metadata specify that B PK has a FK to A PK). In that case the order will be interchanged and OJB first store the main object and then the 1:1 reference.
regards, Armin
--------------------------------------------------------------------- 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]
