Hi John,

McCaffrey, John G. wrote:
I have a DB generated Identity column for Table A and I am able to use OJB
to insert that object A and see what the identity is with a custom
getLastInsertIdentityQuery() method. (Yay!)


Why you don't use SequenceManagerNativeImpl? http://db.apache.org/ojb/sequencemanager.html#nativeSequenceManager

I have a table B that is associated to Table A, but its ID is not generated.
When I insert into Table A and get the generated ID, I would like to insert
into table B and use that same ID. in my mapping for Table A I have a reference descriptor to Table B, with
auto-XXX all true



You can't use auto-udate true in your case, because OJB needs the PK of B to set the FK in A before storing A (assume you declared an 1:1 reference between A and B).
The SequenceManager interface contains two methods only for handle DB identity based key generation:
setReferenceFKs(Object obj, ClassDescriptor cld)
afterStore(JdbcAccess dbAccess, ClassDescriptor cld, Object


If I try to insert Obj A that has an Obj B inside of it, it appears that OJB
tries to insert Obj B first. This will fail because the ID has not been
generated yet.

How can I get OJB to insert Obj A first, then assign that ID to Obj B ?


Think with your current solution it is only possible if you store all objects by hand and set auto-update false. Store B first then set FK in A and store A.


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]



Reply via email to