/** INTERNAL: Ensure that the descriptor has been set. */
  public void checkDescriptor(Object object, AbstractSession session) throws QueryException {
    if (this.descriptor == null) {
      if (object == null) {
        throw QueryException.objectToModifyNotSpecified(this);
      }

      // Bug#3947714  Pass the object instead of class in case object is proxy
      ClassDescriptor referenceDescriptor = session.getDescriptor(object);
      if (referenceDescriptor == null) {
        throw QueryException.descriptorIsMissing(object.getClass(), this);
      }
      setDescriptor(referenceDescriptor);
    }
  }
  /** INTERNAL: Prepare the receiver for execution in a session. */
  public void prepareForExecution() throws QueryException {
    super.prepareForExecution();

    if (getObject() == null) {
      throw QueryException.objectToModifyNotSpecified(this);
    }
    setObject(this.descriptor.getObjectBuilder().unwrapObject(getObject(), getSession()));

    if (this.descriptor == null) {
      setDescriptor(getSession().getDescriptor(getObject().getClass()));
    }

    if (getPrimaryKey() == null) {
      setPrimaryKey(
          this.descriptor
              .getObjectBuilder()
              .extractPrimaryKeyFromObject(getObject(), getSession()));
    }

    if ((getTranslationRow() == null) || (getTranslationRow().isEmpty())) {
      setTranslationRow(
          this.descriptor.getObjectBuilder().buildRowForTranslation(getObject(), getSession()));
    }
  }