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

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

Introduction

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

Prototype

Propagation NEVER

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

Click Source Link

Document

Execute non-transactionally, throw an exception if a transaction exists.

Usage

From source file:com.vmware.bdd.manager.TestClusteringJobs.java

@Test(groups = { "TestClusteringJobs" }, dependsOnMethods = { "testConfigIOShares" })
@Transactional(propagation = Propagation.NEVER)
public void testDeleteCluster() throws Exception {
    long jobExecutionId = clusterMgr.deleteClusterByName(TEST_CLUSTER_NAME);
    ClusterRead cluster = clusterMgr.getClusterByName(TEST_CLUSTER_NAME, false);
    Assert.assertTrue(cluster.getStatus() == ClusterStatus.DELETING,
            "Cluster status should be DELETING, but got " + cluster.getStatus());
    waitTaskFinished(jobExecutionId);//from   w  w w .j  a  v  a 2  s  .c  o  m
    try {
        cluster = clusterMgr.getClusterByName(TEST_CLUSTER_NAME, false);
        Assert.assertTrue(false, "Cluster should not be found.");
    } catch (BddException e) {
        if (e.getErrorId().equals("NOT_FOUND")) {
            Assert.assertTrue(true);
        } else {
            e.printStackTrace();
            Assert.assertTrue(false, "Got unexpected exception");
        }
    }
    assertChildRPRemoved(ConfigInfo.getSerengetiUUID() + "-" + TEST_CLUSTER_NAME);
    assertFolderRemoved(TEST_CLUSTER_NAME);
}

From source file:com.vmware.bdd.manager.TestClusteringJobs.java

@Test(groups = { "TestClusteringJobs" }, dependsOnMethods = { "testDeleteCluster" })
@Transactional(propagation = Propagation.NEVER)
public void testDupDeleteCluster() throws Exception {
    try {/*from   w  w w  .  j ava2s  .c o  m*/
        clusterMgr.deleteClusterByName(TEST_CLUSTER_NAME);
        Assert.assertTrue(false, "Cluster should not be found.");
    } catch (BddException e) {
        if (e.getSection().equals("NOT_FOUND")) {
            Assert.assertTrue(true);
            return;
        }
        e.printStackTrace();
    }
}

From source file:com.newmainsoftech.spray.slingong.datastore.Slim3PlatformTransactionManagerTest.java

@Transactional(propagation = Propagation.NEVER)
protected void neverPropagationCommit() throws Throwable {
    prepTestModels();//w  w w .  j  a  va 2 s .c  o  m

    Assert.assertNull(Datastore.getCurrentGlobalTransaction());

    Datastore.put(a1);
    Datastore.put(a2);
    Datastore.put(b1);
    Datastore.put(b2);
    Datastore.put(a1b2);
    Datastore.put(a2b1);
    Datastore.put(a2b2);
    Datastore.put(b1c1);
    Datastore.put(b1c2);
    Datastore.put(b2c1);
    Datastore.put(b2c2);
}

From source file:com.newmainsoftech.spray.slingong.datastore.Slim3PlatformTransactionManagerTest.java

@Transactional(propagation = Propagation.NEVER)
protected void neverPropagationOnExistingTransaction() throws Throwable {
    prep3rdBookModels(); // Note: Calling non transactional method

    GlobalTransaction gtx = Datastore.getCurrentGlobalTransaction();
    gtx.put(author3, book3, a2book3, book3Chapter1, a3b3Chapter1);
}

From source file:com.newmainsoftech.spray.slingong.datastore.Slim3PlatformTransactionManagerTest.java

@Transactional(propagation = Propagation.NEVER)
protected void neverToRequiredPropagation() throws Throwable {
    prepTestModels();//w ww  . j  ava  2  s. c o  m

    cascadeCommitCallee1(); //  cascadeCommitCallee1 method is annotated with Propagation.REQUIRED
}

From source file:fsl.ta.toms.roms.service.impl.RoadCompliancyServiceImpl.java

@Transactional(propagation = Propagation.NEVER, isolation = Isolation.REPEATABLE_READ, readOnly = true)
public List<ComplianceBO> lookupRoadComplianceActivities(RoadCompliancyCriteriaBO roadCompliancyCriteriaBO) {

    logger.info("In lookupRoadComplianceActivities web service function.");
    List<ComplianceBO> result = new ArrayList<ComplianceBO>();

    result = daoFactory.getRoadCompliancyDAO().lookupRoadComplianceActivities(roadCompliancyCriteriaBO);

    List<OffenceBO> listOfOffences = new ArrayList<OffenceBO>();

    List<RoadCheckBO> listOfRoadChecks = new ArrayList<RoadCheckBO>();

    for (ComplianceBO complianceBO : result) {
        listOfOffences = daoFactory.getRoadCompliancyDAO()
                .getOffencesforCompliance(complianceBO.getComplianceId());
        listOfRoadChecks = daoFactory.getRoadCompliancyDAO()
                .getRoadChecksforCompliance(complianceBO.getComplianceId());

        complianceBO.setListOfOffences(listOfOffences);
        complianceBO.setListOfRoadChecks(listOfRoadChecks);

        listOfOffences = null;/*from   w w  w . ja va2  s .co m*/
        listOfRoadChecks = null;
    }

    return result;
}

From source file:nu.yona.server.subscriptions.service.BuddyService.java

@Transactional(propagation = Propagation.NEVER) // It explicitly creates transactions when needed.
public BuddyDto addBuddyToRequestingUser(UUID idOfRequestingUser, BuddyDto buddy,
        BiFunction<UUID, String, String> inviteUrlGetter) {
    UserDto requestingUser = userService.getPrivateUser(idOfRequestingUser);
    assertMobileNumberOfRequestingUserConfirmed(idOfRequestingUser);
    assertValidBuddy(requestingUser, buddy);

    boolean buddyUserExists = buddyUserExists(buddy);
    if (!buddyUserExists) {
        createAndInviteBuddyUser(idOfRequestingUser, buddy, inviteUrlGetter);
    }/* w ww. ja va 2 s.c o m*/
    BuddyDto savedBuddy = transactionHelper
            .executeInNewTransaction(() -> handleBuddyRequestForExistingUser(idOfRequestingUser, buddy));

    logger.info(
            "User with mobile number '{}' and ID '{}' sent buddy connect message to {} user with mobile number '{}' and ID '{}' as buddy",
            requestingUser.getMobileNumber(), requestingUser.getId(), (buddyUserExists) ? "new" : "existing",
            buddy.getUser().getMobileNumber(), buddy.getUser().getId());

    return savedBuddy;
}

From source file:org.eclipse.hawkbit.repository.jpa.JpaRolloutManagement.java

@Override
// No transaction, will be created per handled rollout
@Transactional(propagation = Propagation.NEVER)
public void handleRollouts() {
    final List<Long> rollouts = rolloutRepository.findByStatusIn(ACTIVE_ROLLOUTS);

    if (rollouts.isEmpty()) {
        return;/*from w w w.  ja v a2s  .  co m*/
    }

    final String tenant = tenantAware.getCurrentTenant();

    final String handlerId = tenant + "-rollout";
    final Lock lock = lockRegistry.obtain(handlerId);
    if (!lock.tryLock()) {
        return;
    }

    try {
        rollouts.forEach(rolloutId -> runInNewTransaction(handlerId + "-" + rolloutId,
                status -> executeFittingHandler(rolloutId)));
    } finally {
        lock.unlock();
    }
}

From source file:org.obiba.opal.core.service.ProjectsServiceImpl.java

@Override
@Transactional(propagation = Propagation.NEVER)
public void save(@NotNull final Project project) throws ConstraintViolationException {
    try {/*from   w w  w.j  a  v a 2s. com*/
        Project original = getProject(project.getName());
        String originalDb = nullToEmpty(original.getDatabase());
        String newDb = nullToEmpty(project.getDatabase());
        if (!newDb.equals(originalDb)) {
            transactionTemplate.execute(new TransactionCallbackWithoutResult() {
                @Override
                protected void doInTransactionWithoutResult(TransactionStatus status) {
                    Datasource datasource = MagmaEngine.get().getDatasource(project.getName());
                    MagmaEngine.get().removeDatasource(datasource);
                    viewManager.unregisterDatasource(datasource.getName());
                    if (datasource.canDrop()) {
                        datasource.drop();
                    }
                }
            });
            databaseRegistry.unregister(originalDb, project.getName());
            registerDatasource(project);
        }
    } catch (NoSuchProjectException e) {
        registerDatasource(project);
    }
    orientDbService.save(project, project);
}