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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
