you have to specify the id generation method on database level (or table level if needed) in *schema.xml:
<database name="customer" defaultIdMethod="idbroker"> or <table name="account" idMethod="idbroker"> we specify always defaultIdMethod="idbroker" on database level and idMethod="none" on table level for tables which doesn't require id generation. btw. i'm still using torque 3.0.2 but i guess it hasn't changed in 3.1... so long Micha > -----Original Message----- > From: Jim Menard [mailto:[EMAIL PROTECTED] > Sent: Thursday, December 18, 2003 5:47 PM > To: Apache Torque Users List > Subject: IDs not generated until after save? > > > 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] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
