当前位置: 首页>>代码示例>>Java>>正文


Java RollbackException类代码示例

本文整理汇总了Java中javax.persistence.RollbackException的典型用法代码示例。如果您正苦于以下问题:Java RollbackException类的具体用法?Java RollbackException怎么用?Java RollbackException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RollbackException类属于javax.persistence包,在下文中一共展示了RollbackException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: update

import javax.persistence.RollbackException; //导入依赖的package包/类
public ConfigurationSubscriptionDto update(long id, ConfigurationSubscriptionDto delta)
    throws ConflictException, NotFoundException {
    try {
        return new TransactionalExecutor<ConfigurationSubscriptionDto>(createEntityManager()).execute((manager) -> {

            ConfigurationSubscriptionDto existingSubscription = findInternal(id, manager);
            if (existingSubscription == null) {
                throw new NotFoundException(Messages.CONFIGURATION_SUBSCRIPTION_NOT_FOUND, id);
            }
            ConfigurationSubscriptionDto result = merge(existingSubscription, delta);
            manager.merge(result);
            return result;

        });
    } catch (RollbackException e) {
        ConfigurationSubscriptionDto subscription = merge(find(id), delta);
        throw new ConflictException(e, Messages.CONFIGURATION_SUBSCRIPTION_ALREADY_EXISTS, subscription.getMtaId(),
            subscription.getAppName(), subscription.getResourceName(), subscription.getSpaceId());
    }
}
 
开发者ID:SAP,项目名称:cf-mta-deploy-service,代码行数:21,代码来源:ConfigurationSubscriptionDtoDao.java

示例2: endTransaction

import javax.persistence.RollbackException; //导入依赖的package包/类
private static void endTransaction(EntityTransaction tx) {
    if (tx != null && tx.isActive()) {
        if (tx.getRollbackOnly()) {
            tx.rollback();
        } else {
            try {
                tx.commit();
            } catch (RollbackException e) {
                if (tx.isActive()) {
                    tx.rollback();
                }
                throw e;
            }
        }
    }
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:17,代码来源:MCRURNGranularRESTRegistrationTask.java

示例3: endTransaction

import javax.persistence.RollbackException; //导入依赖的package包/类
protected void endTransaction() {
    entityManager.ifPresent(em -> {
        EntityTransaction tx = em.getTransaction();
        if (tx != null && tx.isActive()) {
            if (tx.getRollbackOnly()) {
                tx.rollback();
            } else {
                try {
                    tx.commit();
                } catch (RollbackException e) {
                    if (tx.isActive()) {
                        tx.rollback();
                    }
                    throw e;
                }
            }
        }
    });
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:20,代码来源:MCRJPATestCase.java

示例4: incrementSyncCount

import javax.persistence.RollbackException; //导入依赖的package包/类
public boolean incrementSyncCount(String domain, String id, long currentCount) {
    try {
        _main.updateItem(getHashKey(domain), id.toLowerCase())
            .set("syc", currentCount+1)
            .when((expr) -> {
                    if ( 0 == currentCount ) {
                        return expr.or(expr.eq("syc", 0),
                                expr.and(expr.exists("id"), expr.not(expr.exists("syc"))));
                    } else {
                        return expr.eq("syc", currentCount);
                    }
                });
        return true;
    } catch ( RollbackException ex ) {
        return false;
    }
}
 
开发者ID:puppetlabs,项目名称:europa,代码行数:18,代码来源:ContainerRepoDb.java

示例5: addPart

import javax.persistence.RollbackException; //导入依赖的package包/类
public void addPart(String blobId, int partIndex, RegistryBlobPart partId, byte[] oldMDState, byte[] newMDState)
    throws EntityNotFoundException, ConcurrentModificationException
{
    try {
        _main.updateItem(blobId, null)
            .listSet(ATTR_PART_IDS, partIndex, AttrType.MAP, partId)
            .set(ATTR_MD_ENCODED_STATE, AttrType.BIN, newMDState)
            .when((expr) -> expr.and(
                      expr.exists(ATTR_BLOB_ID),
                      ( null == oldMDState )
                      ? expr.not(expr.exists(ATTR_MD_ENCODED_STATE))
                      : expr.eq(ATTR_MD_ENCODED_STATE, oldMDState)));
    } catch ( RollbackException ex ) {
        // Doesn't exist, then throw EntityNotFoundException?
        RegistryBlob blob = _main.getItemOrThrow(blobId, null);
        throw new ConcurrentModificationException(
            "Expected mdState="+(null==oldMDState?"null":printHexBinary(oldMDState))+", but got="+
            (null == blob.getMdEncodedState()?"null":printHexBinary(blob.getMdEncodedState())));
    }
}
 
开发者ID:puppetlabs,项目名称:europa,代码行数:21,代码来源:RegistryBlobDb.java

示例6: finishUpload

import javax.persistence.RollbackException; //导入依赖的package包/类
public void finishUpload(String blobId, byte[] currentMDState, String digest, long size, String mediaType) {
    try {
        UpdateItemBuilder<RegistryBlob> builder = _main.updateItem(blobId, null)
            .remove(ATTR_PART_IDS)
            .remove(ATTR_MD_ENCODED_STATE)
            .remove(ATTR_UPLOAD_ID)
            .set(ATTR_DIGEST, digest.toLowerCase())
            .set(ATTR_SIZE, size);
        if ( null != mediaType ) {
            builder.set(ATTR_MEDIA_TYPE, mediaType);
        }
        builder.when((expr) -> expr.eq(ATTR_MD_ENCODED_STATE, currentMDState));
    } catch ( RollbackException ex ) {
        throw new ConcurrentModificationException(
            "attempt to finish upload of "+blobId+", but the digest state did not match");
    }
}
 
开发者ID:puppetlabs,项目名称:europa,代码行数:18,代码来源:RegistryBlobDb.java

示例7: addReference

import javax.persistence.RollbackException; //导入依赖的package包/类
public Long addReference(String digest, String manifestId) {
    digest = digest.toLowerCase();
    for ( int retry=0;;retry++ ) {
        RegistryBlob blob = getRegistryBlobByDigest(digest);
        if ( null == blob ) return null;
        try {
            return _main.updateItem(blob.getBlobId(), null)
                .setAdd(ATTR_MANIFEST_IDS, AttrType.STR, manifestId)
                .returnAllNew()
                .when((expr) -> expr.exists(ATTR_BLOB_ID))
                .getSize();
        } catch ( RollbackException ex ) {
            log.info(ex.getMessage(), ex);
            // Give up!
            if ( retry > 10 ) return null;
            continue;
        }
    }
}
 
开发者ID:puppetlabs,项目名称:europa,代码行数:20,代码来源:RegistryBlobDb.java

示例8: create

import javax.persistence.RollbackException; //导入依赖的package包/类
@RequestMapping(method = RequestMethod.POST,
value = "/create")
public UserRequestTO create(@RequestBody final UserTO userTO)
        throws UnauthorizedRoleException {

    if (!isCreateAllowedByConf()) {
        LOG.error("Create requests are not allowed");

        throw new UnauthorizedRoleException(-1L);
    }

    LOG.debug("Request user create called with {}", userTO);

    try {
        dataBinder.testCreate(userTO);
    } catch (RollbackException e) {
    }

    UserRequest request = new UserRequest();
    request.setUserTO(userTO);
    request = userRequestDAO.save(request);

    return dataBinder.getUserRequestTO(request);
}
 
开发者ID:ilgrosso,项目名称:oldSyncopeIdM,代码行数:25,代码来源:UserRequestController.java

示例9: update

import javax.persistence.RollbackException; //导入依赖的package包/类
@PreAuthorize("isAuthenticated()")
@RequestMapping(method = RequestMethod.POST,
value = "/update")
public UserRequestTO update(@RequestBody final UserMod userMod)
        throws NotFoundException, UnauthorizedRoleException {

    LOG.debug("Request user update called with {}", userMod);

    try {
        dataBinder.testUpdate(userMod);
    } catch (RollbackException e) {
    }

    UserRequest request = new UserRequest();
    request.setUserMod(userMod);
    request = userRequestDAO.save(request);

    return dataBinder.getUserRequestTO(request);
}
 
开发者ID:ilgrosso,项目名称:oldSyncopeIdM,代码行数:20,代码来源:UserRequestController.java

示例10: delete

import javax.persistence.RollbackException; //导入依赖的package包/类
@PreAuthorize("isAuthenticated()")
@RequestMapping(method = RequestMethod.POST,
value = "/delete")
public UserRequestTO delete(@RequestBody final Long userId)
        throws NotFoundException, UnauthorizedRoleException {

    LOG.debug("Request user delete called with {}", userId);

    try {
        dataBinder.testDelete(userId);
    } catch (RollbackException e) {
    }

    UserRequest request = new UserRequest();
    request.setUserId(userId);
    request = userRequestDAO.save(request);

    return dataBinder.getUserRequestTO(request);
}
 
开发者ID:ilgrosso,项目名称:oldSyncopeIdM,代码行数:20,代码来源:UserRequestController.java

示例11: putDocument

import javax.persistence.RollbackException; //导入依赖的package包/类
/**
 * Renames the current document to the given name.
 *
 * @param renameRequest - the renaming request including id and new name.
 * @return a response with no content if renaming was successful, HTTP 404 if document was not
 *         found or 500 if an error occurred.
 */
@PUT
@Consumes(MediaType.APPLICATION_JSON)
public Response putDocument(DocumentRenameRequest renameRequest) {
  Response response = null;
  try {
    Document affectedDocument = documentDao.findById(id);
    affectedDocument.getMetadata().setTitle(renameRequest.getName());
    affectedDocument.getMetadata().setIsUserDefinedTitle(true);
    documentDao.update(affectedDocument);

    response = Response.noContent().build();
  } catch (EntityNotFoundException enfe) {
    throw new WebApplicationException(enfe, Response.status(Response.Status.NOT_FOUND).build());
  } catch (RollbackException re) {
    throw new WebApplicationException(re);
  }
  return response;
}
 
开发者ID:vita-us,项目名称:ViTA,代码行数:26,代码来源:DocumentService.java

示例12: tratarHibernatePostgreSQL

import javax.persistence.RollbackException; //导入依赖的package包/类
@ExceptionHandler
public void tratarHibernatePostgreSQL(RollbackException e) {
	PersistenceException persistenceException = (PersistenceException) e
			.getCause();
	/*
	 * Desde aquí ya no es estándar JEE6, estas son clases específicas de
	 * Hibernate y PostgreSQL dependiendo del proveedor JPA y del motor que
	 * se utilice esto habrá que adaptar
	 */
	ConstraintViolationException constraintViolationException = (ConstraintViolationException) persistenceException
			.getCause();
	BatchUpdateException batchUpdateException = (BatchUpdateException) constraintViolationException
			.getCause();
	Exception psqlException = batchUpdateException.getNextException();
	String msg = psqlException.getLocalizedMessage();
	logger.error("Error al realizar el update: " + msg);
	FacesContext.getCurrentInstance().addMessage(null,
			new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, null));
}
 
开发者ID:alefq,项目名称:tekoporu-postgresql,代码行数:20,代码来源:UsuarioEditMB.java

示例13: commit

import javax.persistence.RollbackException; //导入依赖的package包/类
public void commit() {
    status = Status.STATUS_NO_TRANSACTION;
    stubCalls.add("commit()");
    if (failCommit) {
        throw new RollbackException();
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:8,代码来源:TransactionInvocationHandlersTest.java

示例14: commit

import javax.persistence.RollbackException; //导入依赖的package包/类
@Override
public void commit() {
    status = Status.STATUS_NO_TRANSACTION;
    stubCalls.add("commit()");
    if (failCommit) {
        throw new RollbackException();
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:9,代码来源:TransactionInvocationHandlersTest.java

示例15: add

import javax.persistence.RollbackException; //导入依赖的package包/类
public ConfigurationSubscriptionDto add(ConfigurationSubscriptionDto subscription) throws ConflictException {
    try {
        return new TransactionalExecutor<ConfigurationSubscriptionDto>(createEntityManager()).execute((manager) -> {

            manager.persist(subscription);
            return subscription;

        });
    } catch (RollbackException e) {
        throw new ConflictException(e, Messages.CONFIGURATION_SUBSCRIPTION_ALREADY_EXISTS, subscription.getMtaId(),
            subscription.getAppName(), subscription.getResourceName(), subscription.getSpaceId());
    }
}
 
开发者ID:SAP,项目名称:cf-mta-deploy-service,代码行数:14,代码来源:ConfigurationSubscriptionDtoDao.java


注:本文中的javax.persistence.RollbackException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。