Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright (c) 2010-2011. Axon Framework
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  *     http://www.apache.org/licenses/LICENSE-2.0
  *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.axonframework.repository;
Exception indicating that the (actual) version of a loaded aggregate did not match the given expected version number. This typically means that the aggregate has been modified by another thread between the moment data was queried, and the command modifying the aggregate was handled.

Author(s):
Allard Buijze
Since:
0.6
    private static final long serialVersionUID = 1827438009942802481L;
    private final AggregateIdentifier aggregateIdentifier;
    private final long expectedVersion;
    private final long actualVersion;

    
Initializes the exception using the given message.

Parameters:
aggregateIdentifier The identifier of the aggregate which version was not as expected
expectedVersion The version expected by the component loading the aggregate
actualVersion The actual version of the aggregate
    public ConflictingAggregateVersionException(AggregateIdentifier aggregateIdentifier,
                                                long expectedVersionlong actualVersion) {
        super(String.format("The version of aggregate [%s] was not as expected. "
                                    + "Expected [%s], but repository found [%s]",
                            aggregateIdentifierexpectedVersionactualVersion));
        this. = aggregateIdentifier;
        this. = expectedVersion;
        this. = actualVersion;
    }

    
Initializes the exception using the given message and cause.

Parameters:
aggregateIdentifier The identifier of the aggregate which version was not as expected
expectedVersion The version expected by the component loading the aggregate
actualVersion The actual version of the aggregate
cause The underlying cause of the exception
    public ConflictingAggregateVersionException(AggregateIdentifier aggregateIdentifier,
                                                long expectedVersionlong actualVersionThrowable cause) {
        super(String.format("The version of aggregate [%s] was not as expected. "
                                    + "Expected [%s], but repository found [%s]",
                            aggregateIdentifierexpectedVersionactualVersion),
              cause);
        this. = aggregateIdentifier;
        this. = expectedVersion;
        this. = actualVersion;
    }

    
Returns the identifier of the aggregate which version is not as expected.

Returns:
the identifier of the aggregate which version is not as expected
        return ;
    }

    
Returns the version expected by the component loading the aggregate.

Returns:
the version expected by the component loading the aggregate
    public long getExpectedVersion() {
        return ;
    }

    
Returns the actual version of the aggregate, as loaded by the repository.

Returns:
the actual version of the aggregate
    public long getActualVersion() {
        return ;
    }
New to GrepCode? Check out our FAQ X