db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Felipe Ramos" <fra...@tissat.es>
Subject Re: Nullable foreign keys
Date Thu, 18 Dec 2003 15:00:30 GMT
You must put in the sschema.xml that language_id has a 
javaType='Object'.   This is the only way to put a null in a column with 

Jim Menard wrote:

> I'm trying to understand how nullable foreign keys work in Torque.
> I have a database table ("member") with a foreign key ("language_id") 
> to another table. The foreign key may be null. When I load a member, 
> it's language is null. Actually, the language_id seems to be set to 0, 
> which really confuses me.
> When I try to save the member with no changes, I see the exception
> ERROR:  member_fk_2 referential integrity violation - key referenced 
> from member not found in language
> Of course not! There is no language record with id 0.
> It looks like NULL foreign keys are stored in Torque as 0, not as 
> NULL. This seems evil to me. When the member tries to save itself, it 
> tries to save 0 into the language_id field, which is not a legal 
> foreign key value. Why does it try to save 0 instead of saving NULL?
> (I can't figure out how to search the mailing list archives. I clicked 
> on the "archive" link in the Torque documentation, but that URL 
> doesn't seem to be good.)
> Thank you for your help.
> Jim

Felipe Ramos
Tissat SA
C/ Orense 34-9ยช
28020 Madrid
Tel: (+34) 91 4175913 
Fax: (+34) 91 4172914
Mail: framos@tissat.es

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

View raw message