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

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

Introduction

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

Prototype

Propagation REQUIRED

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

Click Source Link

Document

Support a current transaction, create a new one if none exists.

Usage

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

@Transactional(propagation = Propagation.REQUIRED)
@Override// w  w w  .  jav  a 2s.  co m
public void addCustomer(Customer customer) {
    try {
        customerDAO.addCustomer(customer);
    } catch (Exception e) {

    }
}

From source file:no.dusken.barweb.service.impl.InvoiceTransaksjonServiceImpl.java

@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, readOnly = false)
public Invoice saveInvoiceAndTransaksjons(Invoice invoice, List<Transaksjon> transaksjons) {
    //  invoice = invoiceService.save(invoice);
    for (Transaksjon t : transaksjons) {
        t.setInvoice(invoice);//w  w w  . j  a  v  a2 s .  c  o  m
    }
    transaksjonService.save(transaksjons);
    return invoice;
}

From source file:com.tsg.dvdlibrarymvc.dao.DvdLibraryDaoDbImpl.java

@Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public DVD addDVD(DVD dvd) {
    jdbcTemplate.update(SQL_INSERT_DVD, dvd.getDvdTitle(), dvd.getDirectorsName(), dvd.getMpaaRating(),
            dvd.getStudio(), dvd.getReleaseDate());
    dvd.setDvdId(jdbcTemplate.queryForObject("select LAST_INSERT_ID()", Integer.class));
    return dvd;/*  w w  w . j ava 2  s  .  co m*/
}

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

@Transactional(propagation = Propagation.REQUIRED)
@Override/*from www . j a va 2s  .c o  m*/
public Product getProduct(int id) {

    try {
        return productDAO.getProduct(id);
    } catch (Exception e) {
        return null;
    }
}

From source file:es.ujaen.iambiental.daos.ReglaSensorActuadorDAO.java

/**
 * Inserta un regla sensor-actuador en la BD.
 *
 * @param reglaSensorActuador// w w  w. j a v  a 2s.c  om
 * @throws ReglaSensorActuadorErrorPersistir
 */
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = es.ujaen.iambiental.excepciones.ReglaSensorActuadorErrorPersistir.class)
public void insertar(ReglaSensorActuador reglaSensorActuador) throws ReglaSensorActuadorErrorPersistir {
    try {
        em.persist(reglaSensorActuador);
        em.flush();
    } catch (Exception e) {
        throw new ReglaSensorActuadorErrorPersistir();
    }
}

From source file:com.webfileanalyzer.service.impl.FilesServiceImpl.java

@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
@Override
public void update(Files dbFile) {
    clearCache();
    filesDAO.update(dbFile);
}

From source file:com.avaje.test.springsupport.UserServiceImpl.java

@Transactional(readOnly = true, propagation = Propagation.REQUIRED)
public User find(long oid) {
    return ebeanServer.find(User.class, oid);
}

From source file:cs544.wamp_blog_engine.service.impl.CategoryTagService.java

@Transactional(propagation = Propagation.REQUIRED)
@Override
public List<Tag> getAllTags() {
    return tagDAO.getAllTags();
}

From source file:com.lewischooman.services.IUserSrv.java

@Transactional(value = "txManager", propagation = Propagation.REQUIRED)
boolean alreadyExists(String uid);

From source file:de.randi2.services.ChartsServiceImpl.java

@Override
@Transactional(propagation = Propagation.REQUIRED)
public ChartData generateRecruitmentChart(Trial trial) {
    trial = trialDao.refresh(trial);/*ww  w.j a v  a2s .c  o  m*/
    ChartData tempD = new ChartData();

    int plannedSubjects = 0;
    for (TreatmentArm arm : trial.getTreatmentArms()) {
        plannedSubjects += arm.getPlannedSubjects();
    }

    List<double[]> data = new ArrayList<double[]>();
    GregorianCalendar startDate = trial.getStartDate();
    GregorianCalendar endDate = trial.getEndDate();
    int monthStart = startDate.get(GregorianCalendar.MONTH);
    int monthEnd = endDate.get(GregorianCalendar.MONTH);
    ArrayList<String> xL = new ArrayList<String>();

    for (int year = startDate.get(GregorianCalendar.YEAR); year <= endDate
            .get(GregorianCalendar.YEAR); year++) {

        if (year != endDate.get(GregorianCalendar.YEAR)) {
            monthEnd = startDate.getMaximum(GregorianCalendar.MONTH);
        } else {
            monthEnd = endDate.get(GregorianCalendar.MONTH);
        }
        for (int month = monthStart; month <= monthEnd; month++) {
            double[] values = new double[2];
            values[0] = 0;
            if (data.size() > 0) {
                values[1] = data.get(data.size() - 1)[1];
            } else
                values[1] = 0;

            for (TrialSubject subject : trial.getSubjects()) {
                if (subject.getCreatedAt().get(GregorianCalendar.MONTH) == month
                        && subject.getCreatedAt().get(GregorianCalendar.YEAR) == year) {
                    values[1] = values[1] + 1.0;
                }
            }
            xL.add((month + 1) + "." + year);
            data.add(values);
        }
        monthStart = startDate.getMinimum(GregorianCalendar.MONTH);
    }

    for (int i = 1; i <= data.size(); i++) {
        data.get(i - 1)[0] = i * (plannedSubjects / data.size());
    }

    tempD.setXLabels(xL);
    tempD.setData(data);
    return tempD;
}