db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steffen Mueller <tor...@mueller.ca>
Subject Null value in foreign key field with Torque?
Date Mon, 19 Jan 2004 17:53:52 GMT
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.EVALUATED_USER));
evaluation.setLrfinancials(Integer.parseInt(lrForm.getLrFinancials()));
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


Mime
View raw message