当前位置: 首页>>代码示例>>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;未经允许,请勿转载。