Andrus Adamchik <andru..bjectstyle.org> wrote:
>
> On May 27, 2004, at 4:56 AM, Tore Halset wrote:
>
> > Hello!
> >
> > My model has a to-one relation A->B that sometimes are empty. Is that
> > supported? How can I test if a B exist for a given A? Checking for
> > (a.getB() == null) does not work. It seems like a.getB returns a empty
> > object with every attribute set to null.
> >
> > Regards,
> > - Tore.
>
> Tore,
>
> I remember this used to be a bug in the past, but this should've been
> fixed long time ago. "a.getB() == null" should work. So the question is
> - what version of Cayenne are you using? And also how is the
> relationship mapped?
I have a similar situation where I allow admin users to view a "deleted"
record in some situations (we mark records "invalidated"=true rather than
actually delete data, then the application's restricting qualifiers
automatically hide these records from the view of the application).
This is how I detect and handle such a dangling one-to-one.
PaymentMethod aPaymentMethod =
aPaymentHistory.getPaymentMethod();
aPaymentMethod.resolveFault();
if (PersistenceState.TRANSIENT !=
aPaymentMethod.getPersistenceState()) // then it exists
else // it doesn't exist
This is used under 1.1M5, I believe.
-Mike
This archive was generated by hypermail 2.0.0 : Thu May 27 2004 - 11:06:11 EDT