I'm trying to confirm my understanding of primary/foreign key associations in newly-created objects. With the code

        BillAccount account = new BillAccount();
        Address address = new Address();
        account.setAddress(address);

        address.save();
        account.save();

I see the exception
ExecInsert: Fail to add null value in not null attribute billing_address_id


Is it true that the address's primary key is not set until after the save? (I've used another Object/Relational package where the id is set in memory before the save.)

If the primary key is not set until after the save, then it looks like I can't associate the address with the account until after the address has been saved. I have to write my code like this instead:

        Address address = new Address();
        address.save();

        BillAccount account = new BillAccount();
        account.setAddress(address);
        account.save();

Thank you for your help.

Jim
--
Jim Menard, [EMAIL PROTECTED], http://www.io.com/~jimm/
"Any sufficiently advanced technology is indistinguishable from a
rigged demo." -- Unknown


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to