Example usage for org.springframework.transaction.annotation Propagation REQUIRES_NEW

List of usage examples for org.springframework.transaction.annotation Propagation REQUIRES_NEW

Introduction

In this page you can find the example usage for org.springframework.transaction.annotation Propagation REQUIRES_NEW.

Prototype

Propagation REQUIRES_NEW

To view the source code for org.springframework.transaction.annotation Propagation REQUIRES_NEW.

Click Source Link

Document

Create a new transaction, and suspend the current transaction if one exists.

Usage

From source file:kr.co.exsoft.common.service.CommonService.java

/**
 * // w ww .ja  v  a  2  s .co m
 * <pre>
 * 1.  : ? ? ? 
 * 2.  :
 * </pre>
 * @Method Name : nextValTable
 * @param String : counter_id
 * @return int
 * @throws Exception
 */
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = { Exception.class, SQLException.class })
public int nextValTable(String counter_id) throws Exception;

From source file:be.peerassistedlearning.repository.StudentRepositoryTest.java

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testAdd() {
    Student s = new Student("David", "paswoord", "davidopdebeeck@hotmail.com", Curriculum.TI, "david",
            UserType.ADMIN);//from  w w w . j a va  2 s.com

    repository.save(s);

    assertNotNull(s.getId());
}

From source file:fr.treeptik.cloudunit.utils.PortUtils.java

/**
 * Find the next free Ssh and Http Proxy Port values and assign to
 * application git ssh and http proxy port property and set used in table
 * Proxy(Ssh or Http)//from ww  w  .j  a v  a 2s .c  om
 */
@Transactional(propagation = Propagation.REQUIRES_NEW)
public Map<String, String> assignProxyPorts(Application application) throws ServiceException {

    logger.debug("-- assignProxyPorts --");

    Map<String, String> mapProxyPorts = new HashMap<String, String>();

    String freeProxySshPortNumber = proxySshPortDAO.findMinFreePortNumber();
    // Gestion du ProxyPort (retrait du pool de ports libres)
    ProxySshPort proxySshPort = proxySshPortDAO.findByPortNumber(freeProxySshPortNumber);
    proxySshPort.setUsed(true);

    logger.info("proxySshPort : " + freeProxySshPortNumber);

    // remplit la map pour transfrer les valeurs  la mthode appelante
    mapProxyPorts.put("freeProxySshPortNumber", freeProxySshPortNumber);

    proxySshPort = proxySshPortDAO.save(proxySshPort);

    return mapProxyPorts;
}

From source file:com.orange.clara.cloud.servicedbdumper.task.ScheduledManagingJobTask.java

@Scheduled(fixedDelay = 1200000)
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void cleaningDeletedDumpFile() {
    logger.debug("Running: cleaning deleted dump task ...");
    List<DatabaseDumpFile> databaseDumpFiles = this.databaseDumpFileRepo.findByDeletedTrueOrderByDeletedAtAsc();
    LocalDateTime whenRemoveDateTime;
    for (DatabaseDumpFile databaseDumpFile : databaseDumpFiles) {
        whenRemoveDateTime = LocalDateTime
                .from(databaseDumpFile.getDeletedAt().toInstant().atZone(ZoneId.systemDefault()))
                .plusDays(this.dumpDeleteExpirationDays);
        if (LocalDateTime.from(Calendar.getInstance().toInstant().atZone(ZoneId.systemDefault()))
                .isBefore(whenRemoveDateTime)) {
            continue;
        }/*w  w  w.j a v  a2  s. c  om*/
        this.deleter.delete(databaseDumpFile);
    }
    logger.debug("Finished: cleaning deleted dump task.");
}

From source file:com.example.securelogin.domain.service.authenticationevent.AuthenticationEventSharedServiceImpl.java

@Transactional(propagation = Propagation.REQUIRES_NEW)
@Override/*from  ww  w .j av a  2  s  . c  o  m*/
public void authenticationSuccess(String username) {
    SuccessfulAuthentication successEvent = new SuccessfulAuthentication();
    successEvent.setUsername(username);
    successEvent.setAuthenticationTimestamp(dateFactory.newTimestamp().toLocalDateTime());

    successAuthenticationRepository.create(successEvent);
    deleteFailureEventByUsername(username);
}

From source file:es.emergya.bbdd.dao.StreetHome.java

@Transactional(readOnly = true, rollbackFor = Throwable.class, propagation = Propagation.REQUIRES_NEW)
public Street get(Integer id) {
    return (Street) getSession().get(Street.class, id);
}

From source file:org.openmrs.module.sync.test.ExampleTransactionalServiceImpl.java

/**
 * Example single transaction// www .j  a  v a2 s  . c o m
 */
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void saveObjectInNewTransaction(OpenmrsObject openmrsObject) {
    session().save(openmrsObject);
}

From source file:com.gradecak.alfresco.mvc.aop.TransactionalAdvice.java

public Object invoke(final MethodInvocation invocation) throws Throwable {
    Class<?> targetClass = invocation.getThis() != null ? invocation.getThis().getClass() : null;

    Method specificMethod = ClassUtils.getMostSpecificMethod(invocation.getMethod(), targetClass);
    // If we are dealing with method with generic parameters, find the original
    // method./*from  w  w  w .ja v a 2  s.  c  om*/
    specificMethod = BridgeMethodResolver.findBridgedMethod(specificMethod);
    AlfrescoTransaction alfrescoTransaction = parseAnnotation(specificMethod);

    if (alfrescoTransaction != null) {
        RetryingTransactionCallback<Object> exampleWork = new RetryingTransactionCallback<Object>() {
            public Object execute() throws Throwable {
                return invocation.proceed();
            }
        };
        boolean readonly = alfrescoTransaction.readOnly();
        Propagation propagation = alfrescoTransaction.propagation();

        boolean requiresNew = Propagation.REQUIRES_NEW.equals(propagation);
        return serviceRegistry.getTransactionService().getRetryingTransactionHelper()
                .doInTransaction(exampleWork, readonly, requiresNew);
    } else {
        return invocation.proceed();
    }

}

From source file:cs544.blog.service.BlogService.java

@Transactional(propagation = Propagation.REQUIRES_NEW)
@Override
public void updateUser(User user) {
    userDAO.updateUser(user);
}

From source file:com.jfootball.business.impl.SeasonServiceImpl.java

@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW)
public void deleteEntity(Long yearID) {

    seasonDao.deleteById(yearID);
}