
/*
 * Copyright (C) 2012 Archie L. Cobbs. All rights reserved.
 *
 * $Id$
 */

package org.dellroad.stuff.pobj;

/**
 * Optimistic locking exception thrown by {@link PersistentObject#setRoot PersistentObject.setRoot()}
 * when the expected version number does not agree.
 */
@SuppressWarnings("serial")
public class PersistentObjectVersionException extends PersistentObjectException {

    private final long actualVersion;
    private final long expectedVersion;

    public PersistentObjectVersionException(long actualVersion, long expectedVersion) {
        this.actualVersion = actualVersion;
        this.expectedVersion = expectedVersion;
    }

    /**
     * Get the actual, unexpected version number.
     */
    public long getActualVersion() {
        return this.actualVersion;
    }

    /**
     * Get the version number that was expected.
     */
    public long getExpectedVersion() {
        return this.expectedVersion;
    }
}


@@ -543,24 +543,123 @@
 dVersion) %7B%0A
+        super(%22expected version %22 + expectedVersion + %22 but actual version was %22 + actualVersion);%0A
         this

Configure exception message.