Re: Testing for Valid Objects

From: Elia Morling (eli..amiljen.se)
Date: Sun Aug 08 2004 - 03:18:43 EDT

  • Next message: Scott McClure: "Re: Testing for Valid Objects"

    If an object does not have a relationship set Cayenne returns an exception.
    Would the best practice be to store an id instead and build a custom
    getParentObject method using a query? All objects without relationships might
    e.g. have the relationship id set to 0.

    Example

    public Object getParent(){
      // Is parentId set to 0? Return null;
      // Else query parent row using parentId;
    }

    ----- Original Message -----
    From: "Mike Kienenberger" <mkienen..laska.net>
    To: "Orion Fields" <ofield..martserv.com>
    Cc: <jsaa..eb.de>; <cayenne-user@objectstyle.org>
    Sent: Friday, August 06, 2004 11:00 PM
    Subject: Re: Testing for Valid Objects

    > =?iso-8859-1?Q? J=FCrgen=20Saar ?= <jsaa..eb.de> wrote:
    > > I use the actual version of cayenne
    > > in difference to 1.0 where silently an empty DataObject was returned
    > > reading the empty relation-object now a CayenneException is thrown.
    >
    > Thanks for the reminder. I thought this problem sounded familiar.
    >
    > Take a look at this from Cayenne Release Notes 1.1 B2:
    >
    > > - DataObject.resolveFault() will now throw an exception if the underlying
    > DB row does not exist
    > > follow this link for further discussion:
    > > http://objectstyle.org/cayenne/lists/cayenne-user/2004/07/0124.html
    >
    > According to this, 1.1B2 started throwing Exceptions in addition to marking
    > the object transient.
    >
    > Also covered in
    > http://objectstyle.org/jira/secure/ViewIssue.jspa?key=CAY-132, so you may
    > want to vote for this issue if it's important to you and you don't like the
    > workaround.
    >
    > Sounds like it's a bug that'll be fixed after 1.1 (so that null is returned
    > instead).
    >
    > -Mike
    >
    >



    This archive was generated by hypermail 2.0.0 : Sun Aug 08 2004 - 03:18:55 EDT