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:org.jrecruiter.service.impl.JobServiceImpl.java

/** {@inheritDoc} */
@Override/*from w  w  w  .  j av  a  2  s  . c o  m*/
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public List<Job> getUsersJobsForStatistics(String username, Integer maxResult) {

    final User user = userDao.getUser(username);

    if (user == null) {
        throw new IllegalArgumentException("No user found for username " + username);
    }

    boolean administrator = false;

    if (AcegiUtil.hasRole(Roles.ADMIN.name())) {
        administrator = true;
    }

    return jobDao.getUsersJobsForStatistics(user.getId(), maxResult, administrator);
}

From source file:es.upm.fiware.rss.expenditureLimit.server.test.ExpenditureLimitServerTest.java

/**
 * //from w w w .java 2 s. c  om
 * @throws Exception
 */
@Transactional(propagation = Propagation.SUPPORTS)
public void deleteProviderExpLimits() throws Exception {
    ExpenditureLimitServerTest.logger.debug("Into deleteProviderExpLimits method");
    Response response = server.deleteProviderExpLimits(aggregator, appProvider, service, currency, type);
    Assert.assertEquals(200, response.getStatus());
}

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

@Transactional(propagation = Propagation.SUPPORTS)
public void testhDeleteAll() {
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setPropagationBehavior(Propagation.REQUIRES_NEW.value());
    TransactionStatus status = transactionManager.getTransaction(def);
    dbeSystemPropertiesDao.deleteAll();/*ww w .  ja va  2  s  . c  o m*/
    transactionManager.commit(status);
    Assert.assertTrue(dbeSystemPropertiesDao.getAll().size() == 0);
}

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

/**
 * {@inheritDoc}/*from   w ww. j a  v  a 2  s .c o m*/
 */
@Override
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public UserDetails loadUserByUsername(final String userName)
        throws UsernameNotFoundException, DataAccessException {

    final User user = userDao.getUserByUsername(userName.trim());

    if (user == null) {
        LOGGER.warn("loadUserByUsername() - No user with id " + userName + " found.");
        throw new UsernameNotFoundException("loadUserByUsername() - No user with id " + userName + " found.");
    }

    LOGGER.info("User {} ({}) loaded.", new Object[] { user.getUsername(), user.getEmail() });

    return user;
}

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

/**
 * //w ww  .  j a  v a 2s  .  co  m
 */
@Transactional(propagation = Propagation.SUPPORTS)
public void checkDbeAppProviderTest() throws RSSException {
    ExpenditureLimitDataCheckerTest.logger.debug("Into checkDbeAppProviderTest mehtod");
    thrown.expect(RSSException.class);
    thrown.expectMessage("AppProvider Not found.");
    checker.checkDbeAppProvider("agg123", "app123456");
    ExpenditureLimitDataCheckerTest.logger.debug("No exception expected");
    checker.checkDbeAppProvider("agg123", "newone");
}

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

@Test
@Transactional(propagation = Propagation.SUPPORTS)
public void testhDeleteAll() {
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setPropagationBehavior(Propagation.REQUIRES_NEW.value());
    TransactionStatus status = transactionManager.getTransaction(def);
    dbeSystemPropertiesDao.deleteAll();//from w  w  w.j av a 2  s  . com
    transactionManager.commit(status);
    Assert.assertTrue(dbeSystemPropertiesDao.getAll().size() == 0);
}

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

@SuppressWarnings("unchecked")
@Transactional(propagation = Propagation.SUPPORTS)
public Utente searchUserByLogin(String login) throws DAOException {
    try {//from w ww. jav  a2s  . c o m
        Session session = getSession();
        Query query = session.createQuery(
                "select utente from Utente utente left join fetch utente.utentiProgetto utentiProgetto where utente.userName = ?");
        query.setParameter(0, login);
        List<Utente> listaUtenti = (List<Utente>) query.list();
        if (listaUtenti.size() != 0)
            return listaUtenti.get(0);
    } catch (HibernateException e) {
        logger.error(Costanti.EXCEPTION_ERROR + e.getMessage());
        throw new DAOException(e.getMessage());
    }
    return null;
}

From source file:com.oak_yoga_studio.service.impl.FacultyServiceImpl.java

@Transactional(propagation = Propagation.SUPPORTS)
@Override//  w  w w  .  j a  v a 2  s .com
public List<Waiver> getfacultyDecidedWaivers(Faculty faculty) {
    try {
        Faculty faculty1 = facultyDAO.getFaculty(faculty.getId());
        List<Customer> advisees = faculty1.getAdvisees();
        List<Waiver> decidedWaivers = new ArrayList();
        System.out.println("before advises");
        for (Customer c : advisees) {
            List<Waiver> waivers = c.getWaivers();
            System.out.println("one advisee");
            for (Waiver w : waivers) {
                System.out.println("waive");
                if (!w.getStatus().equals(Waiver.Status.PENDING)) {
                    decidedWaivers.add(w);
                }
            }
        }
        return decidedWaivers;
    } catch (Exception e) {
        System.out.println("Exception " + e.getMessage());
        return new ArrayList();
    }
}

From source file:org.jrecruiter.service.impl.UserServiceImpl.java

/** {@inheritDoc} */
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public User getUser(String username) {
    return userDao.getUser(username);
}