Package org.springframework.dao

Examples of org.springframework.dao.OptimisticLockingFailureException


       
        public <T extends AggregateRoot> T getByVersionedId(Class<T> expectedType, VersionedId id) {
            T result = expectedType.cast(aggregatesById.get(id.getId()));
            if (result != null) {
                if (!id.nextVersion().equals(result.getVersionedId())) {
                    throw new OptimisticLockingFailureException("actual: " + (result.getVersionedId().getVersion() - 1) + ", expected: " + id.getVersion());
                }
                return result;
            }
           
            try {
View Full Code Here


        } else {
          OperationFuture<CASResponse> casFuture = client.asyncCas(converted.getId(), version,
            converted.getExpiration(), translateEncode(converted), persistTo, replicateTo);
          CASResponse cas = casFuture.get();
          if (cas == CASResponse.EXISTS) {
            throw new OptimisticLockingFailureException("Saving document with version value failed: " + cas);
          } else {
            long newCas = casFuture.getCas();
            beanWrapper.setProperty(versionProperty, newCas);
            return true;
          }
View Full Code Here

          OperationFuture<CASResponse> casFuture = client.asyncCas(converted.getId(), version,
            converted.getExpiration(), translateEncode(converted), persistTo, replicateTo);
          CASResponse cas = casFuture.get();

          if (cas == CASResponse.EXISTS) {
            throw new OptimisticLockingFailureException("Updating document with version value failed: " + cas);
          } else {
            long newCas = casFuture.getCas();
            beanWrapper.setProperty(versionProperty, newCas);
            return true;
          }
View Full Code Here

        if (persistentObject.isVersioned()) {
            if (updateCount > 0) {
                assignNewVersion(o, getVersionColumnToUse(), newVersionValue);
            }
            else {
                throw new OptimisticLockingFailureException("Versioning error for " + o.getClass().getName() + " with " + ((PersistentField)persistentObject.getPersistentFields().get(getVersionColumnToUse())).getFieldName() + " " + oldVersionValue + " and key(s) " + idValues);
            }
        }
    }
View Full Code Here

    }
   
    public void storeEventsIntoStream(UUID streamId, long expectedVersion, EventSource<E> source) {
        EventStream<E> stream = getStream(streamId);
        if (stream.getVersion() != expectedVersion) {
            throw new OptimisticLockingFailureException("stream " + streamId + ", actual version: " + stream.getVersion() + ", expected version: " + expectedVersion);
        }
        stream.setVersion(source.getVersion());
        stream.setTimestamp(source.getTimestamp());
        stream.addEvents(source.getEvents());
    }
View Full Code Here

    }
   
    public void loadEventsFromExpectedStreamVersion(UUID streamId, long expectedVersion, EventSink<E> sink) {
        EventStream<E> stream = getStream(streamId);
        if (stream.getVersion() != expectedVersion) {
            throw new OptimisticLockingFailureException("stream " + streamId + ", actual version: " + stream.getVersion() + ", expected version: " + expectedVersion);
        }
        sink.setType(stream.getType());
        stream.sendEventsAtVersionToSink(stream.getVersion(), sink);
    }
View Full Code Here

                new Date(timestamp),
                stream.getNextEventSequence() + events.size(),
                streamId.toString(),
                expectedVersion);
        if (count != 1) {
            throw new OptimisticLockingFailureException("id: " + streamId + "; actual: " + stream.getVersion() + "; expected: " + expectedVersion);
        }
        if (version < stream.getVersion()) {
            throw new IllegalArgumentException("version cannot decrease");
        }
        if (timestamp < stream.getTimestamp()) {
View Full Code Here

    }

    public void loadEventsFromExpectedStreamVersion(UUID streamId, long expectedVersion, EventSink<E> sink) {
        EventStream stream = getEventStream(streamId);
        if (stream.getVersion() != expectedVersion) {
            throw new OptimisticLockingFailureException("id: " + streamId + "; actual: " + stream.getVersion() + "; expected: " + expectedVersion);
        }
        List<StoredEvent<E>> storedEvents = loadEventsUptoVersion(stream, stream.getVersion());

        sendEventsToSink(stream, storedEvents, sink);
    }
View Full Code Here

    chainedPet2.addDelegate(mpet1);
    assertSame("Should translate differently due to ordering",
        out2, DataAccessUtils.translateIfNecessary(in1, chainedPet2));
   
    RuntimeException in2 = new RuntimeException("in2");
    OptimisticLockingFailureException out3 = new OptimisticLockingFailureException("out2");
    assertNull(chainedPet2.translateExceptionIfPossible(in2));
    MapPersistenceExceptionTranslator mpet3 = new MapPersistenceExceptionTranslator();
    mpet3.addTranslation(in2, out3);
    chainedPet2.addDelegate(mpet3);
    assertSame(out3, chainedPet2.translateExceptionIfPossible(in2));
View Full Code Here

    utControl.replay();

    MockControl synchControl = MockControl.createControl(TransactionSynchronization.class);
    final TransactionSynchronization synch = (TransactionSynchronization) synchControl.getMock();
    synch.beforeCommit(false);
    synchControl.setThrowable(new OptimisticLockingFailureException(""));
    synch.beforeCompletion();
    synchControl.setVoidCallable(1);
    synch.afterCompletion(TransactionSynchronization.STATUS_UNKNOWN);
    synchControl.setVoidCallable(1);
    synchControl.replay();
View Full Code Here

TOP

Related Classes of org.springframework.dao.OptimisticLockingFailureException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.