當前位置: 首頁>>代碼示例>>Java>>正文


Java DefaultTransactionDefinition.setName方法代碼示例

本文整理匯總了Java中org.springframework.transaction.support.DefaultTransactionDefinition.setName方法的典型用法代碼示例。如果您正苦於以下問題:Java DefaultTransactionDefinition.setName方法的具體用法?Java DefaultTransactionDefinition.setName怎麽用?Java DefaultTransactionDefinition.setName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.transaction.support.DefaultTransactionDefinition的用法示例。


在下文中一共展示了DefaultTransactionDefinition.setName方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doInTransaction

import org.springframework.transaction.support.DefaultTransactionDefinition; //導入方法依賴的package包/類
/**
 * @param task
 *            Set the method to run in a transaction
 * @return the object returned by the callable method
 * @throws Exception
 *             if there is a problem running the method
 */
protected final Object doInTransaction(final Callable task)
		throws Exception {
	DefaultTransactionDefinition transactionDefinition = new DefaultTransactionDefinition();
	transactionDefinition.setName("test");
	transactionDefinition
	.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
	TransactionStatus status = transactionManager
			.getTransaction(transactionDefinition);
	Object value = null;
	try {
		value = task.call();
	} catch (Exception ex) {
		transactionManager.rollback(status);
		throw ex;
	}
	transactionManager.commit(status);
	return value;
}
 
開發者ID:RBGKew,項目名稱:eMonocot,代碼行數:26,代碼來源:AbstractPersistenceTest.java

示例2: save

import org.springframework.transaction.support.DefaultTransactionDefinition; //導入方法依賴的package包/類
/**
 * Сохранить календарь.
 */
public void save() {
    QLog.l().logger().info("Save the calendar ID = " + calcId);

    final DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setName("SomeTxName");
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    TransactionStatus status = Spring.getInstance().getTxManager().getTransaction(def);
    try {
        final LinkedList<FreeDay> dels = new LinkedList<>();
        for (FreeDay bad : days_del) {
            boolean f = true;
            for (FreeDay good : days) {
                if (good.equals(bad)) {
                    f = false;
                }
            }
            if (f) {
                dels.add(bad);
            }
        }
        Spring.getInstance().getHt().deleteAll(dels);
        Spring.getInstance().getHt().saveOrUpdateAll(days);
    } catch (Exception ex) {
        Spring.getInstance().getTxManager().rollback(status);
        throw new ClientException(
            "Error performing the operation of modifying data in the database (JDBC).\nPerhaps you added a new calendar, changed it, tried to save the contents of the calendar, but did not save the overall configuration.\nSave the entire configuration (Ctrl + S) and try again to save the contents of the calendar.\n\n["
                + ex.getLocalizedMessage() + "]\n(" + ex.toString() + ")");
    }
    Spring.getInstance().getTxManager().commit(status);
    QLog.l().logger().debug("Saved a new calendar");
    //Type so that there are actual internal data
    days_del = new ArrayList<>(days);
}
 
開發者ID:bcgov,項目名稱:sbc-qsystem,代碼行數:37,代碼來源:CalendarTableModel.java

示例3: saveToSelfDB

import org.springframework.transaction.support.DefaultTransactionDefinition; //導入方法依賴的package包/類
private void saveToSelfDB() {
    // сохраним кастомера в базе
    final DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setName("SomeTxName");
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    TransactionStatus status = Spring.getInstance().getTxManager().getTransaction(def);
    try {
        if (input_data == null) { // вот жеж черд дернул выставить констрейнт на то что введенные данные не нул, а они этот ввод редко нужкн
            //                /Here is the same zhed by the pull of the pull to set the contention that the entered data is not zero, and they rarely need this input
            input_data = "";
        }

        List<Integer> finishStates = Arrays.asList(0, 10, 13);
        if (finishStates.contains(getStateIn())) {
            QLog.l().logQUser().info("Client is in finish state, clear comments...");
            setTempComments("");
        }

        Spring.getInstance().getHt().saveOrUpdate(this);
        QLog.l().logQUser().info("Saved customer");
        // костыль. Если кастомер оставил отзывы прежде чем попал в БД, т.е. во время работы еще с ним.
        // Crutch. If the customizer left a comment before getting into the database, ie. While working with him.
        if (resps.size() > 0) {
            Spring.getInstance().getHt().saveAll(resps);
            resps.clear();
        }
    }
    catch (Exception ex) {
        Spring.getInstance().getTxManager().rollback(status);
        throw new ServerException(
                "Ошибка при сохранении :: Error while saving \n" + ex.toString() + "\n" + Arrays
                        .toString(ex.getStackTrace()));
    }
    Spring.getInstance().getTxManager().commit(status);
    QLog.l().logger().debug("Сохранили.");
}
 
開發者ID:bcgov,項目名稱:sbc-qsystem,代碼行數:37,代碼來源:QCustomer.java

示例4: createTransactionTemplate

import org.springframework.transaction.support.DefaultTransactionDefinition; //導入方法依賴的package包/類
/**
 * Creates the transaction template.
 * <p>
 * This is Hibernate aware if Hibernate is available.
 * 
 * @param repo  the component repository, only used to register secondary items like lifecycle, not null
 * @param hibernateSessionFactory  the session factory, not null
 * @return the template, not null
 */
protected TransactionTemplate createTransactionTemplate(ComponentRepository repo, SessionFactory hibernateSessionFactory) {
  DefaultTransactionDefinition transactionDef = new DefaultTransactionDefinition();
  transactionDef.setName(getName());
  if (getTransactionIsolationLevel() != null) {
    transactionDef.setIsolationLevelName(getTransactionIsolationLevel());
  }
  if (getTransactionPropagationBehavior() != null) {
    transactionDef.setPropagationBehaviorName(getTransactionPropagationBehavior());
  }
  if (getTransactionTimeout() != 0) {
    transactionDef.setTimeout(getTransactionTimeout());
  }
  return new TransactionTemplate(createTransactionManager(repo, hibernateSessionFactory), transactionDef);
}
 
開發者ID:DevStreet,項目名稱:FinanceAnalytics,代碼行數:24,代碼來源:DbConnectorComponentFactory.java

示例5: createTransactionDefinition

import org.springframework.transaction.support.DefaultTransactionDefinition; //導入方法依賴的package包/類
/**
 * Creates the transaction definition.
 * 
 * @return the transaction definition, not null
 */
protected DefaultTransactionDefinition createTransactionDefinition() {
  DefaultTransactionDefinition transDefn = new DefaultTransactionDefinition();
  transDefn.setName(getName());
  if (getTransactionIsolationLevelName() != null) {
    transDefn.setIsolationLevelName(getTransactionIsolationLevelName());
  }
  if (getTransactionPropagationBehaviorName() != null) {
    transDefn.setPropagationBehaviorName(getTransactionPropagationBehaviorName());
  }
  if (getTransactionTimeout() != 0) {
    transDefn.setTimeout(getTransactionTimeout());
  }
  return transDefn;
}
 
開發者ID:DevStreet,項目名稱:FinanceAnalytics,代碼行數:20,代碼來源:DbConnectorFactoryBean.java

示例6: createTransaction

import org.springframework.transaction.support.DefaultTransactionDefinition; //導入方法依賴的package包/類
public static TransactionStatus createTransaction(String name, int propagationBehavior, int isolationLevel, PlatformTransactionManager transactionManager, boolean isReadOnly) {
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setName(name);
    def.setReadOnly(isReadOnly);
    def.setPropagationBehavior(propagationBehavior);
    def.setIsolationLevel(isolationLevel);
    return transactionManager.getTransaction(def);
}
 
開發者ID:passion1014,項目名稱:metaworks_framework,代碼行數:9,代碼來源:TransactionUtils.java

示例7: preHandle

import org.springframework.transaction.support.DefaultTransactionDefinition; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
        throws Exception {
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setName("request");
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);

    TransactionStatus status = txManager.getTransaction(def);
    context.set(status);

    return true;
}
 
開發者ID:kuali,項目名稱:kc-rice,代碼行數:16,代碼來源:TransactionHandlerInterceptor.java

示例8: AutoAssignChecker

import org.springframework.transaction.support.DefaultTransactionDefinition; //導入方法依賴的package包/類
/**
 * Instantiates a new auto assign checker
 *
 * @param targetFilterQueryManagement
 *            to get all target filter queries
 * @param targetManagement
 *            to get targets
 * @param deploymentManagement
 *            to assign distribution sets to targets
 * @param transactionManager
 *            to run transactions
 */
public AutoAssignChecker(final TargetFilterQueryManagement targetFilterQueryManagement,
        final TargetManagement targetManagement, final DeploymentManagement deploymentManagement,
        final PlatformTransactionManager transactionManager) {
    this.targetFilterQueryManagement = targetFilterQueryManagement;
    this.targetManagement = targetManagement;
    this.deploymentManagement = deploymentManagement;

    final DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setName("autoAssignDSToTargets");
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
    def.setReadOnly(false);
    def.setIsolationLevel(Isolation.READ_COMMITTED.value());
    transactionTemplate = new TransactionTemplate(transactionManager, def);
}
 
開發者ID:eclipse,項目名稱:hawkbit,代碼行數:27,代碼來源:AutoAssignChecker.java

示例9: startScheduledActionsByRolloutGroupParentInNewTransaction

import org.springframework.transaction.support.DefaultTransactionDefinition; //導入方法依賴的package包/類
private long startScheduledActionsByRolloutGroupParentInNewTransaction(final Long rolloutId,
        final Long distributionSetId, final Long rolloutGroupParentId, final int limit) {
    final DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setName("startScheduledActions-" + rolloutId);
    def.setReadOnly(false);
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
    return new TransactionTemplate(txManager, def).execute(status -> {
        final Page<Action> rolloutGroupActions = findActionsByRolloutAndRolloutGroupParent(rolloutId,
                rolloutGroupParentId, limit);

        if (rolloutGroupActions.getContent().isEmpty()) {
            return 0L;
        }

        final String tenant = rolloutGroupActions.getContent().get(0).getTenant();

        final List<Action> targetAssignments = rolloutGroupActions.getContent().stream()
                .map(action -> (JpaAction) action).map(this::closeActionIfSetWasAlreadyAssigned)
                .filter(Objects::nonNull).map(this::startScheduledActionIfNoCancelationHasToBeHandledFirst)
                .filter(Objects::nonNull).collect(Collectors.toList());

        if (!CollectionUtils.isEmpty(targetAssignments)) {
            afterCommit.afterCommit(() -> eventPublisher.publishEvent(new TargetAssignDistributionSetEvent(tenant,
                    distributionSetId, targetAssignments, applicationContext.getId())));
        }

        return rolloutGroupActions.getTotalElements();
    });
}
 
開發者ID:eclipse,項目名稱:hawkbit,代碼行數:30,代碼來源:JpaDeploymentManagement.java

示例10: runInNewTransaction

import org.springframework.transaction.support.DefaultTransactionDefinition; //導入方法依賴的package包/類
private <T> T runInNewTransaction(final String transactionName, final TransactionCallback<T> action) {
    final DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setName(transactionName);
    def.setReadOnly(false);
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
    return new TransactionTemplate(txManager, def).execute(action);
}
 
開發者ID:eclipse,項目名稱:hawkbit,代碼行數:8,代碼來源:JpaControllerManagement.java

示例11: runInNewTransaction

import org.springframework.transaction.support.DefaultTransactionDefinition; //導入方法依賴的package包/類
protected Long runInNewTransaction(final String transactionName, final TransactionCallback<Long> action) {
    final DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setName(transactionName);
    def.setReadOnly(false);
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
    return new TransactionTemplate(txManager, def).execute(action);
}
 
開發者ID:eclipse,項目名稱:hawkbit,代碼行數:8,代碼來源:AbstractRolloutManagement.java

示例12: doMigration

import org.springframework.transaction.support.DefaultTransactionDefinition; //導入方法依賴的package包/類
private void doMigration()
{
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setName("migrationRoot");
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    
    TransactionStatus status = null;
    try {
        status = txManager.getTransaction(def);
        Query q = entityManager.createQuery(
                "UPDATE AnnotationFeature \n" +
                "SET type = :fixedType \n" +
                "WHERE type = :oldType \n" +
                "AND name in (:featureNames)");
        
        // This condition cannot be applied: 
        //   "AND layer.type = :layerType"
        //   q.setParameter("layerType", CHAIN_TYPE);
        // http://stackoverflow.com/questions/16506759/hql-is-generating-incomplete-cross-join-on-executeupdate
        // However, the risk that the migration upgrades the wrong featuers is still very low
        // even without this additional condition
        
        q.setParameter("featureNames",
                Arrays.asList(COREFERENCE_RELATION_FEATURE, COREFERENCE_TYPE_FEATURE));
        q.setParameter("oldType", "de.tudarmstadt.ukp.dkpro.core.api.coref.type.Coreference");
        q.setParameter("fixedType", CAS.TYPE_NAME_STRING);
        int changed = q.executeUpdate();
        if (changed > 0) {
            log.info("DATABASE UPGRADE PERFORMED: [{}] coref chain features had their "
                    + "type fixed.", changed);
        }
        txManager.commit(status);
    }
    finally {
        if (status != null && !status.isCompleted()) {
            txManager.rollback(status);
        }
    }
}
 
開發者ID:webanno,項目名稱:webanno,代碼行數:40,代碼來源:FixCoreferenceFeatures.java

示例13: doMigration

import org.springframework.transaction.support.DefaultTransactionDefinition; //導入方法依賴的package包/類
private void doMigration()
{
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setName("migrationRoot");
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    
    TransactionStatus status = null;
    try {
        status = txManager.getTransaction(def);

        for (Project project : projectService.listProjects()) {
            AnnotationLayer tokenLayer = annotationSchemaService.getLayer(
                    Token.class.getName(), project);
            
            // Set attach-feature of Dependency layer to Token.pos if necessary
            fix(project, Dependency.class, RELATION_TYPE, tokenLayer, "pos");

            // Set attach-feature of POS layer to Token.pos if necessary
            fix(project, POS.class, SPAN_TYPE, tokenLayer, "pos");

            // Set attach-feature of Lemma layer to Token.lemma if necessary
            fix(project, Lemma.class, SPAN_TYPE, tokenLayer, "lemma");

            // Set attach-feature of MorphologicalFeatures layer to Token.morph if necessary
            fix(project, MorphologicalFeatures.class, SPAN_TYPE, tokenLayer, "morph");
        }
        
        txManager.commit(status);
    }
    finally {
        if (status != null && !status.isCompleted()) {
            txManager.rollback(status);
        }
    }
}
 
開發者ID:webanno,項目名稱:webanno,代碼行數:36,代碼來源:FixAttachFeature330.java

示例14: getTxStatus

import org.springframework.transaction.support.DefaultTransactionDefinition; //導入方法依賴的package包/類
private TransactionStatus getTxStatus(String action, boolean readOnly, String isolation, String propagation){
	DefaultTransactionDefinition def = new DefaultTransactionDefinition();
	
	def.setName(action);
	
	//Set readOnly configuration
	def.setReadOnly(readOnly);
	
	//Set isolation configuration
	if(isolation.equals(Command.ISOLATION_DEFAULT)){
		def.setIsolationLevel(DefaultTransactionDefinition.ISOLATION_DEFAULT);
	}else if(isolation.equals(Command.ISOLATION_READ_COMMITED)){
		def.setIsolationLevel(DefaultTransactionDefinition.ISOLATION_READ_COMMITTED);
	}else if(isolation.equals(Command.ISOLATION_READ_UNCOMMITED)){
		def.setIsolationLevel(DefaultTransactionDefinition.ISOLATION_READ_UNCOMMITTED);
	}else if(isolation.equals(Command.ISOLATION_REPEATABLE_READ)){
		def.setIsolationLevel(DefaultTransactionDefinition.ISOLATION_REPEATABLE_READ);
	}else if(isolation.equals(Command.ISOLATION_SERIALIZABLE)){
		def.setIsolationLevel(DefaultTransactionDefinition.ISOLATION_SERIALIZABLE);
	}

	//Set propagation configuration
	if(propagation.equals(Command.PROPAGATION_REQUIRED)){
		def.setPropagationBehavior(DefaultTransactionDefinition.PROPAGATION_REQUIRED);
	}else if(propagation.equals(Command.PROPAGATION_MANDATORY)){
		def.setPropagationBehavior(DefaultTransactionDefinition.PROPAGATION_MANDATORY);
	}else if(propagation.equals(Command.PROPAGATION_NESTED)){
		def.setPropagationBehavior(DefaultTransactionDefinition.PROPAGATION_NESTED);
	}else if(propagation.equals(Command.PROPAGATION_NEVER)){
		def.setPropagationBehavior(DefaultTransactionDefinition.PROPAGATION_NEVER);
	}else if(propagation.equals(Command.PROPAGATION_NOT_SUPPORTED)){
		def.setPropagationBehavior(DefaultTransactionDefinition.PROPAGATION_NOT_SUPPORTED);
	}else if(propagation.equals(Command.PROPAGATION_REQUIRES_NEW)){
		def.setPropagationBehavior(DefaultTransactionDefinition.PROPAGATION_REQUIRES_NEW);
	}else if(propagation.equals(Command.PROPAGATION_SUPPORTS)){
		def.setPropagationBehavior(DefaultTransactionDefinition.PROPAGATION_SUPPORTS);
	}
	
	return txManager.getTransaction(def);
}
 
開發者ID:malaguna,項目名稱:cmdit,代碼行數:41,代碼來源:ServiceDelegate.java

示例15: startTransaction

import org.springframework.transaction.support.DefaultTransactionDefinition; //導入方法依賴的package包/類
protected TransactionStatus startTransaction() {
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setName("StatsTransaction");
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    AbstractPlatformTransactionManager txManager = getTransactionManager();
    return txManager.getTransaction(def);
}
 
開發者ID:alancnet,項目名稱:artifactory,代碼行數:8,代碼來源:AbstractStatsService.java


注:本文中的org.springframework.transaction.support.DefaultTransactionDefinition.setName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。