コード例 #1
0
 public void forceLocked(Object entity, Object nextVersion) {
   version = nextVersion;
   loadedState[persister.getVersionProperty()] = version;
   //noinspection deprecation
   setLockMode(LockMode.FORCE); // TODO:  use LockMode.PESSIMISTIC_FORCE_INCREMENT
   persister.setPropertyValue(entity, getPersister().getVersionProperty(), nextVersion);
 }
コード例 #2
0
  /**
   * Handle updating the internal state of the entry after actually performing the database update.
   * Specifically we update the snapshot information and escalate the lock mode
   *
   * @param entity The entity instance
   * @param updatedState The state calculated after the update (becomes the new {@link
   *     #getLoadedState() loaded state}.
   * @param nextVersion The new version.
   */
  public void postUpdate(Object entity, Object[] updatedState, Object nextVersion) {
    this.loadedState = updatedState;
    setLockMode(LockMode.WRITE);

    if (getPersister().isVersioned()) {
      this.version = nextVersion;
      getPersister().setPropertyValue(entity, getPersister().getVersionProperty(), nextVersion);
    }

    if (getPersister().getInstrumentationMetadata().isInstrumented()) {
      final FieldInterceptor interceptor =
          getPersister().getInstrumentationMetadata().extractInterceptor(entity);
      if (interceptor != null) {
        interceptor.clearDirty();
      }
    }
    if (entity instanceof SelfDirtinessTracker)
      ((SelfDirtinessTracker) entity).$$_hibernate_clearDirtyAttributes();

    persistenceContext
        .getSession()
        .getFactory()
        .getCustomEntityDirtinessStrategy()
        .resetDirty(entity, getPersister(), (Session) persistenceContext.getSession());
  }