db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From T E Schmitz <mail...@numerixtechnology.de>
Subject Re: 1. onDelete 2. 1:n association
Date Fri, 30 Jul 2004 10:50:27 GMT
Artur Z wrote:

> Company company = new Company();
> Address address = new Address();
> company.setAddress(address);
> company.save(conn);   // I'd like that this saves also address but it does
> not
> //but the most important thing is that when I call:
> address.save(conn);
> //an exception will be thrown - before the above line I shoul do:
> company.setAddress(address);
> or
> address.setCompany(company);


The address needs to exist in the DB before the company record can be 
saved with a reference to this address.
The generated Torque code only saves the object, not its depencies.

You need to
address.save(conn);
make sure its PK is now in the address object (I think Torque fills this 
automatically). Then
company.setAddress(address);
company.save(conn);

Of course you could generate code that saves all new dependent object 
first and then the object itself. You can generate anything. ;-)

-- 


Regards/Gruß,

Tarlika Elisabeth Schmitz

---------------------------------------------------------------------
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