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

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

Introduction

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

Prototype

Propagation REQUIRES_NEW

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

Click Source Link

Document

Create a new transaction, and suspend the current transaction if one exists.

Usage

From source file:br.com.thiaguten.persistence.demo.hbmcore.HibernatePersistenceProviderImpl.java

@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public <ID extends Serializable, T extends Persistable<ID>> T update(T entity) {
    return super.update(entity);
}

From source file:org.springbyexample.orm.hibernate3.annotation.dao.PersonDaoImpl.java

/**
 * Saves person.//from  ww  w  .ja  va 2s. c  o m
 */
@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW)
public void save(Person person) {
    getHibernateTemplate().saveOrUpdate(person);
}

From source file:com.ciphertool.sentencebuilder.dao.WordDao.java

/**
 * Returns a list of all unique Words, irrespective of parts of speech.
 *///from  w  ww  .  j av a 2  s.c  o  m
@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW)
public List<Word> findAllUniqueWords() {
    Session session = sessionFactory.getCurrentSession();
    @SuppressWarnings("unchecked")
    List<Word> result = (List<Word>) session
            .createQuery("select distinct new Word(id.word, frequencyWeight) from Word").list();

    return result;
}

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

@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = true, rollbackFor = Throwable.class)
public EstadoIncidencia getDefault() {
    try {/*  w w  w. j av a  2 s.  c  o m*/
        Session currentSession = getSession();
        if (currentSession == null) {
            throw new NullPointerException("La sesion de Hibernate es nula");
        }
        Criteria crit = currentSession.createCriteria(EstadoIncidencia.class).add(Restrictions.eq("id", 1l));
        return (EstadoIncidencia) crit.setMaxResults(1).uniqueResult();
    } catch (Throwable t) {
        log.error("Error al sacar el estado por defecto de las incidencias", t);
        return null;
    }
}

From source file:org.simbasecurity.core.audit.provider.DatabaseAuditLogProvider.java

@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void log(AuditLogEvent event) {
    if (this.level.isLoggable(event.getAuditLogLevel())) {
        String ssoToken = event.getSSOToken() == null ? null : event.getSSOTokenString();

        String username = event.getUsername();
        if (username == null) {
            username = NOT_REGISTERED;// w w w.java2  s  . c  o  m
        }
        String remoteIp = event.getRemoteIP();
        if (remoteIp == null) {
            remoteIp = NOT_REGISTERED;
        }

        String digest = null;
        if (isAuditLogIntegrityEnabled()) {
            digest = integrityDigest.digest(AuditLogIntegrityMessageFactory.createDigest(event, ssoToken));
        }

        jdbcTemplate.update(sqlStatement, event.getTimestamp(), username, ssoToken, remoteIp,
                event.getMessage(), event.getName(), event.getFirstName(), event.getUserAgent(),
                event.getHostServerName(), event.getCategory().name(), digest, event.getRequestURL(),
                event.getChainId());
    }
}

From source file:com.glaf.core.id.MyBatisDbIdGenerator.java

@Transactional(propagation = Propagation.REQUIRES_NEW)
public synchronized Long nextId() {
    if (lastId < nextId) {
        getNewBlock();//from  w w  w.  j a va  2 s .c om
    }
    return nextId++;
}

From source file:be.peerassistedlearning.repository.CourseRepositoryTest.java

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testAdd() {
    Course c = new Course("MBI80x", ".NET Programmeren", ".NET", Curriculum.TI, 3);

    repository.save(c);//from  w  w  w  . j  a  v  a  2s.  c  o  m

    assertNotNull(c.getId());
}

From source file:be.peerassistedlearning.repository.RoomRepositoryTest.java

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testAdd() {
    Room r = new Room("2.25", Campus.PROXIMUS, RoomType.COMPUTER);

    repository.save(r);//from  w w w.ja va 2 s. c  o m

    assertNotNull(r.getId());
}

From source file:cs544.blog.service.BlogService.java

@Transactional(propagation = Propagation.REQUIRES_NEW)
@Override
public User loadUser(long userId) {
    return userDAO.loadUser(userId);
}

From source file:org.sharetask.service.SendNotificationJobImpl.java

@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void sendNotification(final Long notificationQueueId) {
    final NotificationQueue notificationQueue = nqRepository.read(notificationQueueId);
    nqRepository.delete(notificationQueue);
    mailService.sendEmail(notificationQueue.getFrom(), notificationQueue.getTo(),
            notificationQueue.getSubject(), notificationQueue.getSubject(), notificationQueue.getRetry());
}