Ejemplo n.º 1
0
  /** 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);
    }
  }
Ejemplo n.º 2
0
  /** 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()));
    }
  }