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

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

Introduction

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

Prototype

Propagation SUPPORTS

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

Click Source Link

Document

Support a current transaction, execute non-transactionally if none exists.

Usage

From source file:it.geosdi.era.server.dao.hibernate.DAOUtenteHibernate.java

@SuppressWarnings("unchecked")
@Transactional(propagation = Propagation.SUPPORTS)
public List<UtenteProgetto> loadUtentiProgetto(long id) {
    List<UtenteProgetto> listaUtentiProgetto = new ArrayList<UtenteProgetto>();
    Session session = getSession();/* w ww.ja  v a  2  s .c  o m*/
    Query query = session.createQuery(
            "select utenteProgetto from UtenteProgetto utenteProgetto where utenteProgetto.utente = ?");
    query.setLong(0, id);
    listaUtentiProgetto = query.list();
    return listaUtentiProgetto;
}

From source file:com.devnexus.ting.core.service.impl.UserServiceImpl.java

@Override
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public User getUser(Long userId) {
    return userDao.getOne(userId);
}

From source file:com.inkubator.sms.gateway.service.impl.RoleServiceImpl.java

@Override
@Transactional(readOnly = true, isolation = Isolation.REPEATABLE_READ, propagation = Propagation.SUPPORTS, timeout = 30)
public List<Role> getAllData() throws Exception {
    return roleDao.getAllData();
}

From source file:es.upm.fiware.rss.expenditureLimit.manager.test.ExpenditureLimitDataCheckerTest.java

/**
 * //from   ww  w . j a v a2  s .c  o m
 */
@Transactional(propagation = Propagation.SUPPORTS)
public void checkChargeTypeTest() throws RSSException {
    ExpenditureLimitDataCheckerTest.logger.debug("Into checkChargeTypeTest mehtod");
    thrown.expect(RSSException.class);
    thrown.expectMessage("chageType Not found.");
    checker.checkChargeType("C");
    ExpenditureLimitDataCheckerTest.logger.debug("No exception expected");
    checker.checkChargeType("N");
}

From source file:com.brienwheeler.svc.authorize_net.impl.CIMClientService.java

@Override
@MonitoredWork// w w  w . j ava2s. com
@GracefulShutdown
// the write logic inside this function is in its own new transaction, so the interceptor can
// treat this as a readOnly transaction
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public String createCustomerProfile(DbId<User> userId) {
    String existingCustomerProfileId = userAttributeService.getAttribute(userId, ATTR_PROFILE_ID);
    if (existingCustomerProfileId != null)
        return existingCustomerProfileId;

    final User user = userService.findById(userId);
    DbValidationUtils.assertPersisted(user);

    CustomerProfile customerProfile = CustomerProfile.createCustomerProfile();
    customerProfile.setMerchantCustomerId(Long.toString(userId.getId()));

    Transaction transaction = createTransaction(TransactionType.CREATE_CUSTOMER_PROFILE);
    transaction.setCustomerProfile(customerProfile);

    Result<Transaction> result = executeTransaction("create profile", userId, transaction);
    final String createdCustomerProfileId = result.getCustomerProfileId();
    log.info("created Authorize.Net customer profile " + createdCustomerProfileId + " for " + user);

    // we want to commit our own transaction to prevent the record from being created at Authorize.Net
    // and then an exception in a calling function that might have a transaction open preventing
    // the save of the UserAttribute recording the customer profile ID
    return transactionWrapper.doInNewWriteTransaction(new Callable<String>() {
        @Override
        public String call() throws Exception {
            try {
                userAttributeService.setAttribute(user, ATTR_PROFILE_ID, createdCustomerProfileId);
            } catch (RuntimeException e) {
                cleanupProfileId(createdCustomerProfileId);
                throw e;
            } catch (Error e) {
                cleanupProfileId(createdCustomerProfileId);
                throw e;
            }
            return createdCustomerProfileId;
        }
    });
}

From source file:com.oak_yoga_studio.dao.impl.EnrollmentDAOImpl.java

@Transactional(propagation = Propagation.SUPPORTS)
@Override// ww  w.  j  a  v  a  2s  . com
public void addEnrollment(Enrollment.statusType status, Customer customer, Section section) {

    Enrollment enrollment = new Enrollment();
    enrollment.setCustomer(customer);
    enrollment.setSection(section);
    enrollment.setEnrollmentDate(new Date());
    enrollment.setStatus(status);

    sf.getCurrentSession().save(enrollment);

}

From source file:se.vgregion.dao.domain.patterns.repository.db.jpa.AbstractJpaRepository.java

/**
 * Does entity manager contain entity?/*  w  w w.j  av a2 s .  c om*/
 * 
 * @param entity
 *            Entity to check for
 * @return true if found
 */
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public boolean contains(T entity) {
    return entityManager.contains(entity);
}

From source file:es.upm.fiware.rss.expenditureLimit.manager.test.ExpenditureLimitManagerTest.java

/**
 * /*from ww w . j a  v a  2s. c o m*/
 */
@Transactional(propagation = Propagation.SUPPORTS)
public void getGeneralUserExpLimits() throws RSSException {
    ExpenditureLimitManagerTest.logger.debug("Into getGeneralUserExpLimits method");
    UserExpenditureLimitInfoBean limits = elManager.getGeneralUserExpLimitsBean(userId, aggregator, appProvider,
            service, currency, type);
    ExpenditureLimitManagerTest.logger.debug("Limits size:" + limits.getGeneralUserLimits());
    Assert.assertEquals(1, limits.getGeneralUserLimits().size());
    Assert.assertEquals(service, limits.getService());
    Assert.assertEquals(currency, limits.getGeneralUserLimits().get(0).getCurrency());
    Assert.assertEquals(type, limits.getGeneralUserLimits().get(0).getType());

}

From source file:se.vgregion.dao.domain.patterns.repository.db.jpa.AbstractJpaRepository.java

/**
 * {@inheritDoc}// w w  w  . ja v a  2  s  . co m
 * 
 */
@SuppressWarnings("unchecked")
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public List<T> findAll() {
    Query query = entityManager.createQuery("select o from " + type.getSimpleName() + " o");
    return query.getResultList();
}