I had just a 5 seconds glance on this, so maybe I'm completely wrong. Have you tried to set the attribute javaType="object" in the foreign key's column definition in the schema.xml ?
Thomas Matteo Barbieri <[EMAIL PROTECTED]> schrieb am 17.02.2006 15:29:22: > After some more tests I found that when I save the second object, Torque > tries to save it with 0 as foreign key, even if second.FkFirstClass() > gives me the correct id of first. > > So what do I do? > > Bye > > Matteo Barbieri ha scritto: > > >Hi, > >maybe it's a stupid question, but I got an error that I don't know why > >it happens. > > > >I have two tables that are related by foreign key. > > > >I have to create one istance of both objects and to save them. > > > >I do something like this: > > > >FirstClass first = new FirstClass(); > >SecondClass second = new SecondClass(); > > > >first.save(); > > > >second.setFirstClass(first); > >second.save(); > > > >the first object is saved correctly, but then I got an SQLException: > > > >java.sql.SQLException: Cannot add or update a child row: a foreign key > >constraint fails > > > >I've tried to print both objects before every saving and the second > >object has the correct foreign key. > > > >Any idea? > > > >Thanks > > > > > > > > > -- > Matteo Barbieri > > > > --------------------------------------------------------------------- > 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]