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.DAOProgettoHibernate.java

@Transactional(propagation = Propagation.SUPPORTS)
public Progetto findById(long idProgetto) throws DAOException {
    List<Progetto> listaProgetti = findByCriteria(Restrictions.eq("id", idProgetto));
    if (listaProgetti.size() != 0)
        return listaProgetti.get(0);
    return null;/* w ww  . j  ava 2 s. c  o m*/
}

From source file:org.nebulae2us.stardust.example.service.impl.CommentServiceImpl.java

@Transactional(propagation = Propagation.SUPPORTS)
public Person getPerson(Long personId) {
    return daoManager.get(Person.class, personId);
}

From source file:es.upm.fiware.rss.expenditureLimit.dao.impl.tests.DbeExpendControlDaoTest.java

@Transactional(propagation = Propagation.SUPPORTS)
public void testUpdateExpendLimitDataForaUser() {

    BmCurrency bmCurrency = new BmCurrency();
    bmCurrency.setNuCurrencyId(1);/*from w w w  .j av  a2s.com*/
    List<DbeExpendControl> l = expLimitDao.getExpendDataForUserAppProvCurrency("userId01", "agg123",
            "app123456", bmCurrency);

    Assert.assertTrue("Elements founds", l != null && l.size() == 3);
    Iterator<DbeExpendControl> it = l.iterator();

    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setPropagationBehavior(Propagation.REQUIRES_NEW.value());
    TransactionStatus status = transactionManager.getTransaction(def);

    while (it.hasNext()) {
        DbeExpendControl el = it.next();
        if (el.getId().getTxElType().equalsIgnoreCase("daily")) {
            el.setFtExpensedAmount(new BigDecimal("0"));
            Date dt = new Date(new Date().getTime() + 23 * 36000 * 1000);
            el.setDtNextPeriodStart(dt);
            el.setTxNotifications("");
        } else {
            el.setFtExpensedAmount(el.getFtExpensedAmount().add(new BigDecimal("22")));
            el.setTxNotifications(el.getTxNotifications() + ", 50");
        }
        expLimitDao.saveDbeExpendControl(el);
    }

    transactionManager.commit(status);

    l = expLimitDao.getExpendDataForUserAppProvCurrency("userId01", "agg123", "app123456", bmCurrency);

    it = l.iterator();
    while (it.hasNext()) {
        DbeExpendControl el = it.next();
        if (el.getId().getTxElType().equalsIgnoreCase("daily")) {
            Assert.assertTrue("Daily accumulate: ", el.getFtExpensedAmount().floatValue() == 0);
            Assert.assertTrue("Notifications: ",
                    el.getTxNotifications() == null || el.getTxNotifications().length() == 0);
        } else {
            Assert.assertTrue("Notifications: ", el.getTxNotifications().contains("50"));
        }
    }
}

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

/**
 * //  ww  w. jav  a2s  .c  om
 * @throws Exception
 */
@Transactional(propagation = Propagation.SUPPORTS)
public void updateUserAccumulated() throws Exception {

    ExpendControl expendControl = generateExpendControl();
    Response response = server.updateUserAccumulated(endUserId, expendControl);
    Assert.assertEquals(201, response.getStatus());
}

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

/** {@inheritDoc} */
@Override/*from www.j  a  v  a  2s  .  com*/
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public List<Job> getUsersJobs(final String username) {

    List<Job> jobs = null;
    User user = userDao.getUser(username);

    boolean administrator = false;

    if (AcegiUtil.containsRole(user.getAuthorities(), Roles.ADMIN.name())) {
        administrator = true;
    }

    if (administrator) {
        jobs = jobDao.getAllJobs();
    } else {
        jobs = jobDao.getAllUserJobs(username);
    }

    return jobs;
}

From source file:info.jtrac.repository.HibernateJtracDao.java

@Override
@Transactional(propagation = Propagation.SUPPORTS)
public Item loadItem(long id) {
    return entityManager.find(Item.class, id);
}

From source file:org.apigw.authserver.svc.impl.CertifiedClientDetailsServiceImpl.java

@Override
@Transactional(propagation = Propagation.SUPPORTS)
public CertifiedClientIcon findClientIconByClientId(String clientId) {
    return certifiedClientRepository.findCertifiedClientIconByClientId(clientId);
}

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

@Transactional(propagation = Propagation.SUPPORTS)
@Override/*from   w w  w .j a  va2s  .  c  o m*/
public List<Customer> getfacultyAdvisees(Faculty faculty) {
    try {
        faculty = facultyDAO.getFaculty(faculty.getId());
        System.out.println("Name is" + faculty.getFirstName());
        return faculty.getAdvisees();
    } catch (Exception e) {
        return new ArrayList();
    }
}

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

/**
 * @throws Exception/*  www.  java  2s  .co  m*/
 */
@Transactional(propagation = Propagation.SUPPORTS)
public void storeGeneralProviderExpLimits() throws Exception {
    ExpenditureLimitServerTest.logger.debug("Into storeGeneralProviderExpLimits method");
    LimitGroupBean expLimits = ExpenditureLimitBeanConstructor.generateLimitGroupBean();
    Response response = server.createModifProviderExpLimit(aggregator, appProvider, expLimits);
    Assert.assertEquals(201, response.getStatus());
}

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

@Transactional(propagation = Propagation.SUPPORTS)
@Override//from ww w  .  j a va  2s.  c  om
public List<Course> getCoursesTaken(int customerID) {

    List<Course> courses;
    List<Customer> cust;
    //e.status ='COMPLETED' AND
    System.out.println("checking enrollments for customer " + customerID);

    Query query = sf.getCurrentSession().createQuery("select distinct co from Customer c  join c.enrollments e "
            + "join e.section s join s.course co where  e.status='COMPLETED' AND c.id=:customerID");

    query.setParameter("customerID", customerID);

    courses = query.list();
    System.out.println("number of courses taken by customer is " + courses.size());
    return courses;

}