db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Manske, Michael" <Michael.Man...@dat.de>
Subject RE: IDs not generated until after save?
Date Thu, 18 Dec 2003 16:57:06 GMT
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:jimm@io.com]
> 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, jimm@io.com, http://www.io.com/~jimm/
> "Any sufficiently advanced technology is indistinguishable from a
> rigged demo." -- Unknown
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message