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:architecture.ee.web.community.profile.DefaultProfileManager.java

@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW)
public void removeProfileImage(ProfileImage image) {
    profileImageCache.remove(image.getProfileImageId());
    profileDao.removeProfileImage(image);
    deleteImageFileCache(image);/* w w  w  . ja  va 2 s .c  o m*/
}

From source file:com.google.ie.business.dao.impl.IdeaDaoImpl.java

@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW)
public boolean updateStatus(Idea idea) {
    String status = idea.getStatus();
    idea = getJdoTemplate().getObjectById(Idea.class, idea.getKey());
    idea.setStatus(status);//w ww  .j a v  a  2s .c o  m
    idea = getJdoTemplate().makePersistent(idea);
    if (idea != null)
        return true;
    return false;
}

From source file:es.tid.fiware.rss.dao.impl.test.DbeSystemPropertiesDaoImplTest.java

@Test
@Transactional(propagation = Propagation.SUPPORTS)
public void testgDeleteById() {
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setPropagationBehavior(Propagation.REQUIRES_NEW.value());
    TransactionStatus status = transactionManager.getTransaction(def);
    dbeSystemPropertiesDao.deleteById("name2");
    transactionManager.commit(status);//from   w w  w. j a  v  a  2 s  .c o  m
    Assert.assertTrue(dbeSystemPropertiesDao.getById("name2") == null);
}

From source file:es.emergya.comunications.MessageGenerator.java

/**
 * @param id//from   www  .  ja va  2  s . c om
 *            Id del mensaje que se debe comprobar si existe o no
 * @return Si el mensaje con id de bandeja de salida <code>id</code> aun
 *         existe en la base de datos.
 */
@Transactional(readOnly = false, rollbackFor = Throwable.class, propagation = Propagation.REQUIRES_NEW)
public static void remove(Long id) {
    try {
        log.info("Cancelando el envo de " + id);
        bandejaSalidaDAO.remove(id);
    } catch (Throwable t) {
        log.error(t, t);
    }
}

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

@SuppressWarnings("unchecked")
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = true, rollbackFor = Throwable.class)
public List<Rol> findByName(String nombreRol) {
    Session currentSession = getSession();
    currentSession.clear();/*ww  w  .  jav a  2s.  c om*/
    return (List<Rol>) currentSession.createCriteria(Rol.class).add(Restrictions.ilike("nombre", nombreRol))
            .addOrder(Order.asc("nombre")).setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).list();
}

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

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testGetById() {
    Review review = new Review(text, s1, l, 5, 5, 5, 5, false);

    reviewRepository.save(review);// www. ja v  a2s .c  o m

    assertEquals(review, reviewRepository.findOne(review.getId()));
}

From source file:architecture.ee.web.site.DefaultWebSiteManager.java

@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW)
public void createWebSite(String name, String description, String displayName, String url,
        boolean allowAnonymousAccess, Company company, User user) throws WebSiteAlreadyExistsExcaption {
    DefaultWebSite site = new DefaultWebSite(name, description, displayName, url, allowAnonymousAccess, true,
            company, user);//w  ww . j a  v  a2s .  co  m
    createWebSite(site);
}

From source file:com.netsteadfast.greenstep.bsc.service.logic.impl.ObjectiveLogicServiceImpl.java

@ServiceMethodAuthority(type = { ServiceMethodType.SELECT })
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = true)
@Override//from   w ww.  ja  v a2s .co m
public String findForMaxObjId(String date) throws ServiceException, Exception {
    if (super.isBlank(date) || !NumberUtils.isNumber(date) || date.length() != 8) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    String maxVisionId = this.objectiveService.findForMaxObjId(BscConstants.HEAD_FOR_OBJ_ID + date);
    if (StringUtils.isBlank(maxVisionId)) {
        return BscConstants.HEAD_FOR_OBJ_ID + date + "001";
    }
    int maxSeq = Integer.parseInt(maxVisionId.substring(11, 14)) + 1;
    if (maxSeq > 999) {
        throw new ServiceException(
                SysMessageUtil.get(GreenStepSysMsgConstants.DATA_ERRORS) + " over max seq 999!");
    }
    return BscConstants.HEAD_FOR_OBJ_ID + date + StringUtils.leftPad(String.valueOf(maxSeq), 3, "0");
}

From source file:org.finra.dm.service.impl.EmrServiceImpl.java

/**
 * Gets details of an existing EMR Cluster. Creates its own transaction.
 *
 * @param emrClusterAlternateKeyDto, the EMR cluster alternate key
 * @param emrClusterId, the cluster id of the cluster to get details
 * @param emrStepId, the step id of the step to get details
 * @param verbose, parameter for whether to return detailed information
 * @param retrieveOozieJobs parameter for whether to retrieve oozie job information
 *
 * @return the EMR Cluster object with details.
 * @throws Exception//from  w  w w.  ja  va2  s. c  o m
 */
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public EmrCluster getCluster(EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, String emrClusterId,
        String emrStepId, boolean verbose, boolean retrieveOozieJobs) throws Exception {
    return getClusterImpl(emrClusterAlternateKeyDto, emrClusterId, emrStepId, verbose, retrieveOozieJobs);
}

From source file:net.firejack.platform.core.store.process.CaseStore.java

/**
 * Finds case by ID//  w w  w . j  a  v  a2  s  .  c o m
 *
 * @param id - ID of the case
 * @return found case
 */
@Override
@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW)
public CaseModel findById(Long id) {
    CaseModel processCase = super.findById(id);
    if (processCase != null) {
        Hibernate.initialize(processCase.getAssignee());
        if (processCase.getAssignee() != null) {
            processCase.getAssignee().setUserRoles(null);
        }
        Hibernate.initialize(processCase.getStatus());
        Hibernate.initialize(processCase.getCaseObjectModels());
    }
    return processCase;
}