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:be.peerassistedlearning.repository.LessonRepositoryTest.java

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testUpdate() {
    lessonRepository.save(l1);/*w w w  .j ava  2s . c  o  m*/

    assertNotNull(l1.getId());

    l1.setDuration(90L);

    Lesson l3 = lessonRepository.findOne(l1.getId());

    assertEquals(l1, l3);
}

From source file:com.jaspersoft.jasperserver.api.engine.common.service.impl.HibernateLoggingService.java

@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
public void log(LogEvent event) {
    prepareForSave(event);
    getHibernateTemplate().save(event);
}

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

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testRemove() {
    Tutor t = new Tutor(s1, courses);

    tutorRepository.save(t);/*  ww  w  .  java2s . com*/
    tutorRepository.delete(t);

    assertNull(tutorRepository.findOne(t.getId()));
}

From source file:net.firejack.platform.core.store.registry.ActorStore.java

/**
 * @param id actor id/*from  w w w . j  av a2  s  . c o m*/
 * @return actor
 * @see IActorStore#findById(java.lang.Long)
 */
@Override
@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW)
public ActorModel findById(final Long id) {
    ActorModel actor = super.findById(id);
    if (actor != null) {
        Hibernate.initialize(actor.getUserActors());
        if (actor.getUserActors() != null) {
            for (UserActorModel userActor : actor.getUserActors()) {
                userActor.setProcess(null);
                userActor.setActor(null);
                if (userActor.getUser() != null) {
                    userActor.getUser().setUserRoles(null);
                }
            }
        }
        Hibernate.initialize(actor.getRoles());
        if (actor.getRoles() != null) {
            for (RoleModel role : actor.getRoles()) {
                role.setPermissions(null);
            }
        }
        Hibernate.initialize(actor.getGroups());
        if (actor.getGroups() != null) {
            for (GroupModel group : actor.getGroups()) {
                group.setDirectory(null);
            }
        }
    }
    return actor;
}

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

@Transactional(propagation = Propagation.REQUIRES_NEW)
@Override
public void deletePost(long postId) {
    postDAO.deletePost(postId);
}

From source file:com.parakhcomputer.web.dao.ThemeDaoImpl.java

/**
 * Deletes theme.
 */
@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW)
public void delete(Theme theme) {
    em.remove(em.merge(theme));
}

From source file:org.brekka.pegasus.core.services.impl.AbstractEMailSendingService.java

@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public EMailMessage send(final Collection<String> recipients, final String sender, final String subject,
        final String plainBody, final String htmlBody, final KeySafe<?> keySafe) {
    return send(recipients, sender, subject, plainBody, htmlBody, Collections.<Attachment>emptyList(), keySafe);
}

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

@Transactional(readOnly = true, rollbackFor = Throwable.class, propagation = Propagation.REQUIRES_NEW)
@Override/*from  ww w.  ja  v  a  2  s.  com*/
public Recurso 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.orange.clara.cloud.servicedbdumper.task.job.JobFactory.java

@Transactional(propagation = Propagation.REQUIRES_NEW)
public void createJobCreateDump(DbDumperServiceInstance dbDumperServiceInstance, Metadata metadata) {
    Job job = this.createJobWithDatabaseRefSrc(JobType.CREATE_DUMP, dbDumperServiceInstance.getDatabaseRef(),
            dbDumperServiceInstance);//from   www . j  a v  a  2s  . co  m
    job.setMetadata(metadata);
    this.jobRepo.save(job);
}

From source file:org.trpr.platform.core.impl.persistence.PersistenceDelegate.java

/**
 * Deletes the specified PersistentEntity using the specified PersistenceProvider. Note that this method is transactional by default.
 * It is advisable to use {@link PersistenceManagerProvider#makeTransient(PersistentEntity)} instead of calling this method directly.
 * @param entity the PersistentEntity to delete
 * @param provider the PersistenceProvider to use in deletion
 * @throws PersistenceException in case of deletion errors
 */// w  ww .j  a  va2  s . c o m
@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW, isolation = Isolation.DEFAULT, rollbackForClassName = {
        "Exception" })
public void makeTransient(PersistentEntity entity, PersistenceProvider provider) throws PersistenceException {
    provider.makeTransient(entity);
}