You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by Thomas Fischer <fi...@seitenbau.net> on 2010/10/01 21:31:14 UTC

"throws TorqueException" in setter for referenced object by a foreign key

This question is best explained by an example

If I have
  <table name="book" description="Book table">
    ....
    <foreign-key foreignTable="author">
      <reference local="author_id" foreign="author_id"/>
    </foreign-key>
  </table>
then Torque generates (complexObjectModel=true) in BaseBook:

    public void setAuthor(Author v) throws TorqueException
    {
        if (v == null)
        {
            setAuthorId(0);
        }
        else
        {
            setAuthorId(v.getAuthorId());
        }
        aAuthor = v;
    }

and the question is: why does this method declares to throw a
TorqueException? In the code it is never thrown.

I intend to make this behaviour configurable using the option
torque.om.complexObjectModel.localFieldSetterException
If the default value is set to to TorqaueException, the behaviour of 3.3 is
retained.
But I'd rather set the default behaviour to not throwing an exception
because it forces the user to write unnecessary catch clauses for
exceptions which are never thrown. Any objections ?

       Thomas


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Re: "throws TorqueException" in setter for referenced object by a foreign key

Posted by Thomas Fischer <fi...@seitenbau.net>.
> On 01.10.10 21:31, Thomas Fischer wrote:
> > I intend to make this behaviour configurable using the option
> > torque.om.complexObjectModel.localFieldSetterException
> > If the default value is set to to TorqaueException, the behaviour of
3.3 is
> > retained.
> > But I'd rather set the default behaviour to not throwing an exception
> > because it forces the user to write unnecessary catch clauses for
> > exceptions which are never thrown. Any objections ?
>
> I don't think it is useful to retain a feature like that at all. Just
> drop the exception.

Hm, not so sure. Exception handling is a beast. Somebody may rely on it.
But on the other hand, people will complain if they do and we can always
re-add it then. I'll just drop it.

https://issues.apache.org/jira/browse/TORQUE-148

   Thomas


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Re: "throws TorqueException" in setter for referenced object by a foreign key

Posted by Thomas Vandahl <tv...@apache.org>.
On 01.10.10 21:31, Thomas Fischer wrote:
> I intend to make this behaviour configurable using the option
> torque.om.complexObjectModel.localFieldSetterException
> If the default value is set to to TorqaueException, the behaviour of 3.3 is
> retained.
> But I'd rather set the default behaviour to not throwing an exception
> because it forces the user to write unnecessary catch clauses for
> exceptions which are never thrown. Any objections ?

I don't think it is useful to retain a feature like that at all. Just
drop the exception.

Bye, Thomas.

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org