db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Giulio Vezzelli" <giulio.vezze...@infolog.it>
Subject R: Null value in foreign key field with Torque?
Date Mon, 19 Jan 2004 17:56:04 GMT
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 : giulio.vezzelli@infolog.it
 
 

> -----Messaggio originale-----
> Da: Steffen Mueller [mailto:torque@mueller.ca] 
> Inviato: lunedì 19 gennaio 2004 18.54
> A: torque-user@db.apache.org
> 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: 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