Beispiel #1
0
  /**
   * Creates a snapshot of the entity.
   *
   * @since 2.0.0
   */
  private void snapshot() {
    ManagedInstance.LOG.trace("Snapshot generated for instance {0}", this);

    if (this.snapshot.size() == 0) {
      for (final AbstractMapping<?, ?, ?> mapping : this.type.getMappingsSingular()) {
        this.snapshot.put(mapping, mapping.get(this.instance));
      }
    }
  }
Beispiel #2
0
  private boolean checkUpdatedImpl() {
    // iterate over old values
    for (final AbstractMapping<?, ?, ?> mapping : this.type.getMappingsSingular()) {
      final Object newValue = mapping.get(this.instance);
      final Object oldValue = this.snapshot.get(mapping);

      // if it is changed then mark as changed and bail out
      if (mapping.getAttribute().getPersistentAttributeType() == PersistentAttributeType.BASIC) {
        if (!ObjectUtils.equals(oldValue, newValue)) {
          return true;
        }

        continue;
      }

      if (oldValue != newValue) {
        return true;
      }
    }

    return false;
  }