Package info.archinnov.achilles.type

Examples of info.archinnov.achilles.type.Options$CASCondition



    @Test
    public void should_add_timestamp_to_statement_if_ordered_batch() throws Exception {
        //Given
        Options options = noOptions();
        batch = new Batch(null, contextFactory, daoContext, configContext, true);

        //When
        final Options actual = batch.maybeAddTimestampToStatement(options);

        //Then
        assertThat(actual.getTimestamp()).isNotNull();
    }
View Full Code Here


    @Test
    public void should_init_persistence_context_with_entity() throws Exception {
        // Given
        Object entity = new Object();
        Options options = OptionsBuilder.noOptions();
        PersistenceContext context = mock(PersistenceContext.class);
        PersistenceContext.PersistenceManagerFacade operations = mock(PersistenceContext.PersistenceManagerFacade.class);

        when(contextFactory.newContextWithFlushContext(entity, options, flushContext)).thenReturn(context);
        when(context.getPersistenceManagerFacade()).thenReturn(operations);
View Full Code Here

    @Test
    public void should_init_persistence_context_with_primary_key() throws Exception {
        // Given
        Object primaryKey = new Object();
        Options options = OptionsBuilder.noOptions();
        PersistenceContext context = mock(PersistenceContext.class);
        PersistenceContext.PersistenceManagerFacade operations = mock(PersistenceContext.PersistenceManagerFacade.class);

        when(contextFactory.newContextWithFlushContext(Object.class, primaryKey, options, flushContext)).thenReturn(context);
        when(context.getPersistenceManagerFacade()).thenReturn(operations);
View Full Code Here

public class ConsistencyOverrider {

    private static final Logger log = LoggerFactory.getLogger(ConsistencyOverrider.class);

    public Options overrideRuntimeValueByBatchSetting(Options options, AbstractFlushContext flushContext) {
        Options result = options;
        if (flushContext.type() == BATCH && flushContext.getConsistencyLevel() != null) {
            result = options.duplicateWithNewConsistencyLevel(flushContext.getConsistencyLevel());
        }
        return result;
    }
View Full Code Here

     * @return proxified entity
     */
    @Override
    public <T> T insert(final T entity, Options options) {
        log.debug("Inserting entity '{}' and options '{}'", entity, options);
        Options modifiedOptions = adaptOptionsForBatch(options);
        return super.asyncInsert(entity, modifiedOptions).getImmediately();
    }
View Full Code Here

     * @param options options
     */
    @Override
    public void update(Object entity, Options options) {
        log.debug("Updating entity '{}' with options {} ", proxifier.getRealObject(entity), options);
        Options modifiedOptions = adaptOptionsForBatch(options);
        super.asyncUpdate(entity, modifiedOptions).getImmediately();
    }
View Full Code Here

     * @param entity  Managed entity to be inserted/updated
     * @param options options
     */
    public <T> T insertOrUpdate(T entity, Options options) {
        log.debug("Inserting or updating entity '{}' with options {}", proxifier.getRealObject(entity), options);
        Options modifiedOptions = adaptOptionsForBatch(options);
        return super.insertOrUpdate(entity, modifiedOptions);
    }
View Full Code Here

     * @param options options for consistency level and timestamp
     */
    @Override
    public void delete(final Object entity, Options options) {
        log.debug("Removing entity '{}' with options {}", proxifier.getRealObject(entity), options);
        Options modifiedOptions = adaptOptionsForBatch(options);
        super.asyncDelete(entity, modifiedOptions).getImmediately();
    }
View Full Code Here

     * @param primaryKey  Primary key
     */
    @Override
    public void deleteById(Class<?> entityClass, Object primaryKey, Options options) {
        log.debug("Deleting entity of type '{}' by its id '{}'", entityClass, primaryKey);
        Options modifiedOptions = maybeAddTimestampToStatement(options);
        super.asyncDeleteById(entityClass, primaryKey, modifiedOptions).getImmediately();
    }
View Full Code Here

        log.trace("Initializing new persistence context for entity {}", entity);
        return contextFactory.newContextWithFlushContext(entity, options, flushContext).getPersistenceManagerFacade();
    }

    protected Options adaptOptionsForBatch(Options options) {
        Options modifiedOptions = maybeAddTimestampToStatement(options);
        if (!optionsValidator.isOptionsValidForBatch(modifiedOptions)) {
            flushContext = flushContext.duplicateWithNoData(defaultConsistencyLevel);
            throw new AchillesException("Runtime custom Consistency Level and/or async listeners cannot be set for batch mode. Please set the Consistency Levels at batch start with 'startBatch(consistencyLevel)' and async listener using endBatch(...)");
        }
        return modifiedOptions;
View Full Code Here

TOP

Related Classes of info.archinnov.achilles.type.Options$CASCondition

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.