Java Code Examples for javax.transaction.Transactional.TxType#REQUIRES_NEW

The following examples show how to use javax.transaction.Transactional.TxType#REQUIRES_NEW . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IntegrationQueryServiceImpl.java    From we-cmdb with Apache License 2.0 6 votes vote down vote up
@Transactional(TxType.REQUIRES_NEW)
@Override
public List<IntQueryOperateAggResponseDto> operateAggregationQuery(int ciTypeId, List<IntQueryOperateAggRequetDto> aggRequests) {
    if (logger.isDebugEnabled()) {
        logger.debug("operateAggregationQuery with ciTypeId:{}, aggRequests: {}", ciTypeId, JsonUtil.toJson(aggRequests));
    }

    List<IntQueryOperateAggResponseDto> responseDtos = new ArrayList<>(aggRequests.size());
    aggRequests.forEach(x -> {
        IntQueryAggOperation operation = IntQueryAggOperation.fromCode(x.getOperation());
        if (IntQueryAggOperation.None.equals(operation)) {
            throw new InvalidArgumentException(String.format("Wrong operation [%s] for integration aggreation query request.", x.getOperation()));
        }
        responseDtos.add(operateAggregationQueryUnit(ciTypeId, x, operation));
    });

    if (logger.isDebugEnabled()) {
        logger.debug("operateAggregationQuery response: {}", JsonUtil.toJson(responseDtos));
    }
    return responseDtos;
}
 
Example 2
Source File: MutinyTransactionalBean.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@Transactional(value = TxType.REQUIRES_NEW)
public void doInTx() {
    Assertions.assertEquals(0, Person.count());

    Person entity = new Person();
    entity.name = "Stef";
    entity.persist();
}
 
Example 3
Source File: MutinyTransactionalBean.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@Transactional(value = TxType.REQUIRES_NEW)
public Uni<String> doInTxUni() {
    Assertions.assertEquals(0, Person.count());

    Person entity = new Person();
    entity.name = "Stef";
    entity.persist();

    return Uni.createFrom().item("OK");
}
 
Example 4
Source File: MutinyTransactionalBean.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@Transactional(value = TxType.REQUIRES_NEW)
public Multi<String> doInTxMulti() {
    Assertions.assertEquals(0, Person.count());

    Person entity = new Person();
    entity.name = "Stef";
    entity.persist();

    return Multi.createFrom().items("OK");
}
 
Example 5
Source File: TransactionalBean.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@Transactional(value = TxType.REQUIRES_NEW)
public void doInTx() {
    Assertions.assertEquals(0, ContextEntity.count());

    ContextEntity entity = new ContextEntity();
    entity.name = "Stef";
    entity.persist();
}
 
Example 6
Source File: TransactionalBean.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@Transactional(value = TxType.REQUIRES_NEW)
public Single<String> doInTxSingle() {
    Assertions.assertEquals(0, ContextEntity.count());

    ContextEntity entity = new ContextEntity();
    entity.name = "Stef";
    entity.persist();

    return Single.just("OK");
}
 
Example 7
Source File: TransactionalBean.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@Transactional(value = TxType.REQUIRES_NEW)
public Flowable<String> doInTxPublisher() {
    Assertions.assertEquals(0, ContextEntity.count());

    ContextEntity entity = new ContextEntity();
    entity.name = "Stef";
    entity.persist();

    return Flowable.fromArray("OK");
}
 
Example 8
Source File: IntegrationQueryServiceImpl.java    From we-cmdb with Apache License 2.0 4 votes vote down vote up
@Transactional(TxType.REQUIRES_NEW)
@Override
public int createIntegrationQuery(int ciTypeId, String queryName, IntegrationQueryDto intQueryDto) {
    if (logger.isDebugEnabled()) {
        logger.debug("Creating integrate query for ciTypeId [{}] queryName:{} intQueryDto:{}", ciTypeId, queryName, JsonUtil.toJsonString(intQueryDto));
    }
    intQueryDto.validate();

    List<AdmIntegrateTemplate> intQuerys = intTempRepository.findAllByName(queryName);
    if(intQuerys != null && intQuerys.size()>0){
        throw new InvalidArgumentException(String.format("The given integration name (%s) is existed.",queryName));
    }

    AdmIntegrateTemplate intTemplate = new AdmIntegrateTemplate();
    intTemplate.setName(queryName);
    intTemplate.setDes(queryName);
    intTemplate.setCiTypeId(ciTypeId);

    intTemplate = buildIntegrateTempl(intQueryDto, intTemplate, null, null);

    // validate selection
    if (intTemplate.getAdmIntegrateTemplateAlias().size() == 0) {
        throw new InvalidArgumentException("Please select at leaset one CI.");
    }

    AtomicInteger attrCount = new AtomicInteger(0);
    intTemplate.getAdmIntegrateTemplateAlias().forEach(x -> {
        attrCount.addAndGet(x.getAdmIntegrateTemplateAliasAttrs().size());
    });
    if (attrCount.get() == 0) {
        throw new InvalidArgumentException("Please select at least one attribute.");
    }

    intTempRepository.save(intTemplate);
    intTemplAliasRepository.saveAll(intTemplate.getAdmIntegrateTemplateAlias());
    intTemplate.getAdmIntegrateTemplateAlias().forEach(x -> {
        intTemplAliasAttrRepository.saveAll(x.getAdmIntegrateTemplateAliasAttrs());
        intTemplRltRepository.saveAll(x.getChildIntegrateTemplateRelations());
    });
    logger.info("Created integrate template:{}", intTemplate.getIdAdmIntegrateTemplate());
    return intTemplate.getIdAdmIntegrateTemplate();
}
 
Example 9
Source File: TransactionalTestServiceImpl.java    From camunda-bpm-spring-boot-starter with Apache License 2.0 4 votes vote down vote up
@Override
@Transactional(TxType.REQUIRES_NEW)
public void doThrowing() {
  doOk();
  throw new IllegalStateException();
}
 
Example 10
Source File: TransactionService.java    From cloudbreak with Apache License 2.0 4 votes vote down vote up
@Override
@Transactional(TxType.REQUIRES_NEW)
public <T> T requiresNew(Supplier<T> callback) {
    return callback.get();
}
 
Example 11
Source File: TransactionService.java    From cloudbreak with Apache License 2.0 4 votes vote down vote up
@Override
@Transactional(TxType.REQUIRES_NEW)
public void requiresNew(Runnable callback) {
    callback.run();
}
 
Example 12
Source File: TransactionalTestServiceImpl.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Override
@Transactional(TxType.REQUIRES_NEW)
public void doThrowing() {
  doOk();
  throw new IllegalStateException();
}