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.bia.ccm.services.impl.OrderServiceImpl.java

@Override
@Transactional(propagation = Propagation.REQUIRED)
public void deleteOrder(Long orderId, Long organization) {
    OrderDetail od = orderDetailDao.find(orderId);
    orderDetailDao.delete(od);//w  w  w . j  a  v a 2 s  .c om
}

From source file:fr.gael.dhus.util.DownloadActionRecordListener.java

@Override
@Transactional(propagation = Propagation.REQUIRED)
public void bytesTransferred(long total_bytes_transferred, int bytes_transferred, long stream_size) {
    /*/*from   ww w . j a v a  2 s . com*/
    logger.info ("Transfert [" + bytes_transferred  + "/" + 
       total_bytes_transferred + " on " + stream_size + "]" );
    */

    if ((total_bytes_transferred == bytes_transferred) && !started) {
        ActionRecordWritterDao writer = ApplicationContextProvider.getBean(ActionRecordWritterDao.class);

        writer.downloadStart(this.uuid, stream_size, user.getUsername());
        start = new Date().getTime();
        started = true;
        logger.info("Product '" + this.uuid + "' (" + this.identifier + ") " + "download by user '"
                + user.getUsername() + "' started -> " + stream_size);
        return;
    }

    if (bytes_transferred == -1) {
        ActionRecordWritterDao writer = ApplicationContextProvider.getBean(ActionRecordWritterDao.class);

        if (total_bytes_transferred == stream_size) {
            long end = new Date().getTime();
            logger.info("Product '" + this.uuid + "' (" + this.identifier + ") " + "download by user '"
                    + user.getUsername() + "' completed in " + (end - start) + "ms -> " + stream_size);

            writer.downloadEnd(this.uuid, stream_size, user);
        } else {
            long end = new Date().getTime();
            logger.info("Product '" + this.uuid + "' (" + this.identifier + ") " + "download by user '"
                    + user.getUsername() + "' failed at " + total_bytes_transferred + "/" + stream_size + " in "
                    + (end - start) + "ms ");

            writer.downloadFailed(this.uuid, total_bytes_transferred, user.getUsername());
        }
    }
}

From source file:com.acmeair.jpa.service.BookingServiceImpl.java

@Transactional(propagation = Propagation.REQUIRED)
@Override/*from  w  ww. ja v  a  2  s . c  o m*/
public BookingPK bookFlight(String customerId, FlightPK flightId) {
    try {
        // We still delegate to the flight and customer service for the map
        // access than getting the map instance directly
        Flight f = flightService.getFlightByFlightKey(flightId);
        Customer c = customerService.getCustomerByUsername(customerId);

        Booking newBooking = new Booking(keyGenerator.generate().toString(), new Date(), c, f);
        BookingPK key = newBooking.getPkey();

        em.persist(newBooking);

        return key;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

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

@Transactional(propagation = Propagation.REQUIRED)
@Override
public List<Product> getAllProducts() {
    List<Product> products = productDAO.getAllProducts();
    return products;
}

From source file:org.lamop.riche.services.SourceServiceImpl.java

@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
@Override//w w w  .jav a2s  .c  om
public void addEntity(Source entity) {
    Set<RelationSourcePerson> list = entity.getRelationPerson();
    for (Iterator<RelationSourcePerson> iterator = list.iterator(); iterator.hasNext();) {
        RelationSourcePerson get = iterator.next();

        //        }
        //        for (int i = 0; i < list.size(); i++) {
        //            RelationSourcePerson get = list.get(i);
        Person person = daoPerson.getEntity(get.getPerson().getId());
        get.setPerson(person);
        get.setSource(entity);
    }
    dao.addEntity(entity);
}

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

@Transactional(readOnly = true, rollbackFor = Throwable.class, propagation = Propagation.REQUIRED)
@Override/* w  w  w. ja  va  2  s.c o m*/
public Outbox get(Long id) {
    try {
        return super.get(id);
    } catch (Throwable t) {
        log.error("Estamos buscando un objeto que no existe", t);
        return null;
    }
}

From source file:com.mycompany.addressbookmvc.dao.AddressDaoDbImpl.java

@Override
@Transactional(propagation = Propagation.REQUIRED)
public Address create(Address address) {
    jdbcTemplate.update(SQL_INSERT_ADDRESS, address.getFirstName(), address.getLastName(),
            address.getStreetNumber(), address.getStreetName(), address.getCity(), address.getState(),
            address.getZip());/*w w w.j  a v  a 2  s .c om*/

    Integer id = jdbcTemplate.queryForObject("SELECT LAST_INSERT_ID()", Integer.class);

    address.setId(id);

    return address;
}

From source file:com.devicehive.service.IdentityProviderService.java

@Transactional(propagation = Propagation.REQUIRED)
public IdentityProviderVO update(@NotNull String providerName, IdentityProviderVO identityProvider) {
    if (!StringUtils.equals(providerName, identityProvider.getName())) {
        throw new IllegalParametersException(String.format(Messages.IDENTITY_PROVIDER_NAME_CHANGE_NOT_ALLOWED,
                providerName, identityProvider.getName()));
    }//from w ww. j a  va 2 s .c om
    IdentityProviderVO existing = find(providerName);
    if (existing == null) {
        throw new IllegalParametersException(String.format(Messages.IDENTITY_PROVIDER_NOT_FOUND, providerName));
    }
    if (identityProvider.getName() != null) {
        existing.setName(identityProvider.getName());
    }
    if (identityProvider.getApiEndpoint() != null) {
        existing.setApiEndpoint(identityProvider.getApiEndpoint());
    }
    hiveValidator.validate(existing);
    return identityProviderDao.merge(existing);
}

From source file:DataBaseAcessLayer.AccountDAOImpl.java

@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
public void saveAccount(Compte account) {
    org.hibernate.classic.Session session = hibernateTemplate.getSessionFactory().getCurrentSession();
    session.saveOrUpdate(account);//w w w .  j  a v a2s  .  c om

    System.out.println(account.toString());
}

From source file:com.mycompany.flooringmvc.dao.OrderDaoDbImpl.java

@Override
@Transactional(propagation = Propagation.REQUIRED)
public Order get(Integer id) {
    return jdbc.queryForObject(SQL_GET_ORDER, new OrderMapper(), id);
}