You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Eric Emminger <er...@ericemminger.com> on 2003/02/18 21:45:44 UTC

Re: Nullable columns as foreign keys fail

Hi Tuncay

> Now, when I try to create a Task object and call save method I get a "cannot
> add child row, foreign key rule fails" message from MySQL. After long hours
> of digging in the source I found that when Criteria prepares the SQL it
> always puts "parent_id" column into the list. From my point of view, when I
> set required="false" Torque should not insist of taking "parent_id" into
> account. Is this a known problem, or am I making a mistake?

To create a top-level task, try explicitly setting parent_id to NULL.

Criteria crit = new Criteria();
crit.add(TaskPeer.PARENT_ID, (Object) (TaskPeer.PARENT_ID + " IS NULL"),
    Criteria.CUSTOM);

Does that work?

Eric

-- 
Eric Emminger
eric@ericemminger.com