subclass of CayenneRuntimeException for => PersistenceState.TRANSIENT under 1.1RC1

From: Mike Kienenberger (mkienen..laska.net)
Date: Mon Oct 18 2004 - 22:03:31 EDT

  • Next message: Andrus Adamchik: "Re: subclass of CayenneRuntimeException for => PersistenceState.TRANSIENT under 1.1RC1"

    I've been running my unit tests after upgrading from 1.1M5-ish to RC1.

    The one major issue I still seem to have is this.

        /**
         *..ince 1.1
         */
        public void resolveFault() {
            if (getPersistenceState() == PersistenceState.HOLLOW && dataContext
    != null) {
                dataContext.getObjectStore().resolveHollow(this);
                if (getPersistenceState() != PersistenceState.COMMITTED) {
                    throw new CayenneRuntimeException(
                            "Error resolving fault, no matching row exists in
    the database for ObjectId: "
                                    + getObjectId());
                }
            }
        }

    Before, when I "deleted" (made invisible via a restricting qualifier) an
    object and invalidated it, the object got set to PersistenceState.TRANSIENT.
      In the one location where I expected this to happen, I could detect this
    situation with code as follows:

                        // If the fault doesn't resolve, then the payment method
    must have been invalidated
                        aPaymentMethod.resolveFault();
                        if (PersistenceState.TRANSIENT ==
    aPaymentMethod.getPersistenceState())

    Unfortunately, as things stand in the code above, I have to trap all
    CayenneRuntimeExceptions in order to detect this condition and allow my code
    to continue running.

    I'm not opposed to an exception being thrown (in fact, I think it's a good
    idea), but can we make the exception thrown a subclass of
    CayenneRuntimeException so it can be easily detected apart from general
    database errors? The thought of having to parse the exception message text
    to determine this does not appeal to me.

    -Mike



    This archive was generated by hypermail 2.0.0 : Mon Oct 18 2004 - 22:02:22 EDT