Bug in prepareForAcces..aseContext ?

From: Andreas Pardeike (a..sys.se)
Date: Tue Mar 18 2008 - 09:55:21 EDT

  • Next message: Andreas Pardeike: "Re: Bug in prepareForAcces..aseContext ?"

    Hi,

    maybe I am totally off here, but I just tried to find out why my to-
    one relationship did not work and I went and traced the code for
    3.0M3. Seems something is wrong in prepareForAcces..aseContext:

    This is my version and to me this looks like 'objects[0]' is never
    really used (see marker ? >>>>). As a result,
    'object.getPersistenceState()' will of course still be
    PersistenceState.HOLLOW and the FaultFailureException is thrown.

    Regards,
    Andreas Pardeike

         public void prepareForAccess(Persistent object, String property,
    boolean lazyFaulting) {
            if (object.getPersistenceState() == PersistenceState.HOLLOW) {

                ObjectId oid = object.getObjectId();
                List<?> objects = performQuery(new ObjectIdQuery(oid,
    false, ObjectIdQuery.CACHE));

                if (objects.size() == 0) {
                    throw new FaultFailureException(
                            "Error resolving fault, no matching row exists
    in the database for ObjectId: "
                                    + oid);
                }
                else if (objects.size() > 1) {
                    throw new FaultFailureException(
                            "Error resolving fault, more than one row
    exists in the database for ObjectId: "
                                    + oid);
                }
    ? >>>>
                // sanity check...
                if (object.getPersistenceState() !=
    PersistenceState.COMMITTED) {

                    String state =
    PersistenceState.persistenceStateName(object
                            .getPersistenceState());

                    // TODO: andrus 4/13/2006, modified and deleted states
    are possible due to
                    // a race condition, should we handle them here?

                    throw new FaultFailureException(
                            "Error resolving fault for ObjectId: "
                                    + oid
                                    + " and state ("
                                    + state
                                    + "). Possible cause - matching row is
    missing from the database.");
                }
            }

            // resolve relationship fault
            if (lazyFaulting && property != null) {
                Property propertyDescriptor =
    getEntityResolver().getClassDescriptor(
                         
    object.getObjectId().getEntityName()).getProperty(property);

                // this should trigger fault resolving
                propertyDescriptor.readProperty(object);
            }
        }



    This archive was generated by hypermail 2.0.0 : Tue Mar 18 2008 - 09:55:55 EDT