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:org.fuin.auction.query.server.AuctionMessageListener.java

@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public final void onMessage(final Message message) {

    if (LOG.isDebugEnabled()) {
        LOG.debug(message.toString());/* www  .  j  a v  a 2 s.c  o  m*/
    }

    try {

        if (message instanceof ObjectMessage) {
            final ObjectMessage objectMessage = (ObjectMessage) message;
            try {
                final Serializable obj = objectMessage.getObject();
                if (obj instanceof CategoryCreatedMessage) {
                    handleMessage((CategoryCreatedMessage) obj);
                } else if (obj instanceof CategoryMarkedForDeletionMessage) {
                    handleMessage((CategoryMarkedForDeletionMessage) obj);
                } else if (obj instanceof CategoryDeletedMessage) {
                    handleMessage((CategoryDeletedMessage) obj);
                } else if (obj instanceof UserRegisteredMessage) {
                    handleMessage((UserRegisteredMessage) obj);
                } else if (obj instanceof UserEmailVerifiedMessage) {
                    handleMessage((UserEmailVerifiedMessage) obj);
                } else if (obj instanceof UserPasswordChangedMessage) {
                    handleMessage((UserPasswordChangedMessage) obj);
                } else {
                    LOG.warn("Received non-Auction message: " + obj);
                }
            } catch (final JMSException ex) {
                LOG.error("Error reading object from message", ex);
            }
        } else {
            LOG.warn("Received non-Object message: " + message);
        }

    } catch (final RuntimeException ex) {
        LOG.error("Error handling message", ex);
    }

}

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

@Scheduled(fixedDelay = 300000)
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void cleaningFinishedJobs() {
    logger.debug("Running: cleaning job scheduled task ...");
    jobFactory.purgeJob();//from  w w  w .  ja v  a  2  s  .c  o m
    logger.debug("Finished: cleaning job scheduled task.");
}

From source file:org.fuin.auction.query.server.AuctionQueryServiceImpl.java

@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public final List<CategoryDto> findAllCategories() {
    final List<Category> categories = categoryDao.findAll();
    final List<CategoryDto> result = new ArrayList<CategoryDto>();
    for (final Category category : categories) {
        // TODO michael Create domain object to dto converter structure
        result.add(new CategoryDto(category.getId(), category.getName(), category.isActive()));
    }//from   w w w  . j  a  v a  2s.  co m
    return result;
}

From source file:com.glaf.core.id.MyBatisDbIdGenerator.java

@Transactional(propagation = Propagation.REQUIRES_NEW)
public synchronized String getNextId(String name) {
    return Long.toString(this.nextId(name));
}

From source file:com.sshdemo.common.security.web.authentication.rememberme.JPAPersistentTokenRepository.java

@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW)
public void updateToken(String series, String tokenValue, Date lastUsed) {

    RememberMeToken model = rememberMeTokenDAO.get(series);
    model.setToken(tokenValue);/*  www .  j  a va  2  s. c om*/
    model.setLastUsed(lastUsed);
    rememberMeTokenDAO.persist(model);
}

From source file:cn.org.once.cstack.service.impl.MessageServiceImpl.java

@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public Message create(Message message) throws ServiceException {
    try {//from w  w  w .  jav  a 2  s  .c o  m
        message.setCuInstanceName(cuInstanceName);
        return messageDAO.save(message);
    } catch (PersistenceException e) {
        throw new ServiceException(e.getLocalizedMessage(), e);
    }
}

From source file:com.ciphertool.zodiacengine.dao.SolutionDao.java

@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW)
public List<SolutionChromosome> findByCipherName(String cipherName) {
    // First find the Cipher by name
    Query selectByCipherNameQuery = new Query(Criteria.where("name").is(cipherName));

    Cipher cipher = mongoOperations.findOne(selectByCipherNameQuery, Cipher.class);

    // Then find the Solutions that correspond to this Cipher
    Query selectByCipherIdQuery = new Query(Criteria.where("cipherId").is(cipher.getId()));

    List<SolutionChromosome> solutions = mongoOperations.find(selectByCipherIdQuery, SolutionChromosome.class);

    return solutions;
}

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

@Override
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = true, rollbackFor = Throwable.class)
public Configuracion get(String id) {
    try {/* w w w. j av  a  2 s.c  o  m*/
        return super.get(id);
    } catch (Throwable t) {
        log.error("Estamos buscando un objeto que no existe", t);
        return null;
    }
}

From source file:fr.xebia.demo.objectgrid.spring.TestServiceImpl.java

@Transactional(propagation = Propagation.REQUIRES_NEW)
public String queryNewTx() throws ObjectGridException {
    Session s = txManager.getSession();/*from ww w  .  j a va 2s  .co  m*/
    System.out.println("QueryTX using " + s);
    ObjectMap m = s.getMap("TEST");
    return (String) m.get("Hello");
}

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

@Transactional(propagation = Propagation.REQUIRES_NEW)
@Override
public User getUser(String username) {
    return userDAO.getUser(username);
}