Uploaded image for project: 'Cayenne'
  1. Cayenne
  2. CAY-1832

Exception when modifying objects in postLoad callback

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.2.M1
    • 3.2.M1
    • Core Library
    • None

    Description

      Say you have a postLoad callback on an entity that calls a setter on the object, for example:

      public void publicCallback(Object entity) {
      Artist a = (Artist)entity;
      a.setArtistName("Changed");
      }

      This works if you fetch the object directly with a SelectQuery. But if you fault in the object through a relationship it will call BaseContext.prepareForAccess which has this:

      // 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(... }

      Since the object is modified (not committed) an exception is thrown. It is valid to allow mutating an object during postLoad.

      Attachments

        Activity

          People

            johnthuss John Huss
            johnthuss John Huss
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: