You must set javaType="object" in the schema, for the INTEGER column which is a foreign key.
Regards, Giulio Vezzelli Infolog S.r.l. Via Alfieri, 28 Modena - 41100 Telefono : +39-059-822446 Sito web : http://www.infolog.it E-mail : [EMAIL PROTECTED] > -----Messaggio originale----- > Da: Steffen Mueller [mailto:[EMAIL PROTECTED] > Inviato: luned� 19 gennaio 2004 18.54 > A: [EMAIL PROTECTED] > Oggetto: Null value in foreign key field with Torque? > > Hi, > > I would like to create an object and store it in the > database. The object has a reference to another object (or > table). However, the reference is voluntary (so: can be null): > > > Evaluation evaluation = new Evaluation(); > > evaluation.setEmployee((Employee) > httpServletRequest.getSession().getAttribute(Constants.EVALUAT > ED_USER)); > evaluation.setLrfinancials(Integer.parseInt(lrForm.getLrFinanc > ials())); > evaluation.setLrprocesses(Integer.parseInt(lrForm.getLrProcesses())); > evaluation.setCreationip(httpServletRequest.getRemoteAddr()); > evaluation.setCreationdate(Calendar.getInstance().getTime()); > > evaluation.save(); > > > If I just ignore the foreign key field, called Transfer, the > database returns the following error: > > org.apache.torque.TorqueException: ORA-02291: integrity constraint > (LQA.EVALUATION_FK_6) violated - parent key not found > > This is because Torque internally sets the variable to "0" as > opposed to null. And then, obviously, the integrity is > violated. This problem must occur in many projects, and I > would greatly appreciate if you guys would let me know how > you solved this problem. > > I really wonder why Torque is not using Java Objects like > Integer, etc.??? > > Steffen > > > --------------------------------------------------------------------- > 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]
