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


Java JpaSystemException类代码示例

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


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

示例1: persistAndRetryIfMacCollision

import org.springframework.orm.jpa.JpaSystemException; //导入依赖的package包/类
private VmNicVO persistAndRetryIfMacCollision(VmNicVO vo) {
    int tries = 5;
    while (tries-- > 0) {
        try {
            vo = dbf.persistAndRefresh(vo);
            return vo;
        } catch (JpaSystemException e) {
            if (e.getRootCause() instanceof MySQLIntegrityConstraintViolationException &&
                    e.getRootCause().getMessage().contains("Duplicate entry")) {
                logger.debug(String.format("Concurrent mac allocation. Mac[%s] has been allocated, try allocating another one. " +
                        "The error[Duplicate entry] printed by jdbc.spi.SqlExceptionHelper is no harm, " +
                        "we will try finding another mac", vo.getMac()));
                logger.trace("", e);
                vo.setMac(NetworkUtils.generateMacWithDeviceId((short) vo.getDeviceId()));
            } else {
                throw e;
            }
        }
    }
    return null;
}
 
开发者ID:zstackio,项目名称:zstack,代码行数:22,代码来源:VmAllocateNicFlow.java

示例2: handleJpaException

import org.springframework.orm.jpa.JpaSystemException; //导入依赖的package包/类
/**
 * 处理JPA的异常
 *
 * @param ex
 * @param request
 * @return
 */
@ExceptionHandler(value = {JpaSystemException.class})
public ResponseEntity<ErrorResponse> handleJpaException(Exception ex, WebRequest request) {

    if (log.isDebugEnabled()) {
        log.debug("handling exception ==> " + request.getDescription(true));
    }

    RestException rex = new RestException(PARAMS_RESOLUTION_ERROR, ex.getLocalizedMessage());
    ErrorResponse res = new ErrorResponse(rex);

    return new ResponseEntity<>(res, rex.getHttpStatus());
}
 
开发者ID:lordking,项目名称:spring-rest-sample,代码行数:20,代码来源:GlobalExceptionHandler.java

示例3: testDuplicateUniqueValuesAreRejectedWithChecking_TestingDisabled

import org.springframework.orm.jpa.JpaSystemException; //导入依赖的package包/类
@Test
public void testDuplicateUniqueValuesAreRejectedWithChecking_TestingDisabled() {
	myDaoConfig.setUniqueIndexesCheckedBeforeSave(false);

	createUniqueBirthdateAndGenderSps();

	Patient pt1 = new Patient();
	pt1.setGender(Enumerations.AdministrativeGender.MALE);
	pt1.setBirthDateElement(new DateType("2011-01-01"));
	myPatientDao.create(pt1).getId().toUnqualifiedVersionless();

	try {
		myPatientDao.create(pt1).getId().toUnqualifiedVersionless();
		fail();
	} catch (JpaSystemException e) {
		// good
	}
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:19,代码来源:FhirResourceDaoR4UniqueSearchParamTest.java

示例4: delete

import org.springframework.orm.jpa.JpaSystemException; //导入依赖的package包/类
@RequestMapping(value = "/{configType}_configs/{configName}", method = RequestMethod.DELETE, produces = "text/html")
public String delete(@PathVariable String configType, @PathVariable("configName") String configName, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, Model uiModel) throws Exception {
    Configuration configuration = Configuration.findConfigurationsByNameEquals(configName).getSingleResult();
    try {
        for (Transformer t:configuration.getTransformers()) t.removeOrphanedWiredTransformers(); // this is expensive and should go soon
        configuration.remove();
    } catch (JpaSystemException e) {
        // assuming a possibly still exotically ocurring legacy error: a wire
        // of a *different* config uses this matcher, hence it would have a
        // foreign key into the void and complains so the matcher can't be
        // deleted and this config neither..
        configuration.fixMatchersForAlienWire();
        configuration.getWiring().clear();
        configuration.merge();
        configuration.removeTransformers();
        configuration = Configuration.findConfigurationsByNameEquals(configName).getSingleResult();
        configuration.remove();
    }
    uiModel.asMap().clear();
    uiModel.addAttribute("page", (page == null) ? "1" : page.toString());
    uiModel.addAttribute("size", (size == null) ? "10" : size.toString());
    return String.format("redirect:/%s_configs", configType);
}
 
开发者ID:RBGKew,项目名称:Reconciliation-and-Matching-Framework,代码行数:24,代码来源:CustomConfigController.java

示例5: delete

import org.springframework.orm.jpa.JpaSystemException; //导入依赖的package包/类
@UICommand
@Override
public String delete()
{
  String copyName = getEntity().getName();

  try {
    Library library = getEntity().getLibrary();
    getDao().deleteEntity(getEntity());
    showMessage("deletedEntity", "copy " + copyName);
    _libraryViewer.getContextualSearchResults().reload();
    return _libraryViewer.viewEntity(library);
  }
  catch (JpaSystemException e) {
    if (e.contains(ConstraintViolationException.class)) {
      showMessage("cannotDeleteEntityInUse", "Copy " + copyName);
      return REDISPLAY_PAGE_ACTION_RESULT;
    }
    else {
      throw e;
    }
  }
}
 
开发者ID:hmsiccbl,项目名称:screensaver,代码行数:24,代码来源:LibraryCopyDetail.java

示例6: test02_CreateYourEntity_DuplicateEntry

import org.springframework.orm.jpa.JpaSystemException; //导入依赖的package包/类
@Test(expected = JpaSystemException.class)
public void test02_CreateYourEntity_DuplicateEntry() {
    LOGGER.info("Running: test02_CreateYourEntity");
    YourEntity yourEntity = new YourEntity();
    yourEntity.setEntityEmailAddress(USER_EMAIL);  // Will Fail since it is not Unique ...
    yourEntity.setCredentials("password");
    yourEntity.setEntityGivenName("Ro");
    yourEntity.setEntitySurname("Bot");
    yourEntity.setStatus(YourEntityStatus.ACTIVE);
    yourEntity.setYourEntityRoles(new HashSet<>());
    yourEntity.setEntityProperties(new HashMap<>());
    yourEntity.setYourEntityOrganizations(new HashSet<>());

    identityProviderEntityManager.saveYourEntity(yourEntity);
}
 
开发者ID:jaschenk,项目名称:Your-Microservice,代码行数:16,代码来源:IdPEMYourEntityIT.java

示例7: handleOtherExceptions

import org.springframework.orm.jpa.JpaSystemException; //导入依赖的package包/类
/**
 * Geef HTTP code 500 bij JPA fouten.
 * @param ex exception
 * @return fout omschrijving
 */
@ExceptionHandler(JpaSystemException.class)
@ResponseBody
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ExceptionResponse handleOtherExceptions(final JpaSystemException ex) {
    LOG.warn("JPA exceptie opgetreden", ex);
    return new ExceptionResponse(
            "Databaseregels geschonden",
            "Ingevoerde gegevens komen al voor in de database of schenden integriteitsregels van de database");
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:15,代码来源:ErrorHandler.java

示例8: testSaveWithExistingEntityWithNullId

import org.springframework.orm.jpa.JpaSystemException; //导入依赖的package包/类
@Test
public void testSaveWithExistingEntityWithNullId() throws Exception {
    final RealizationEntity entity = getRealizationEntity();
    final RealizationEntity saved = repository.saveAndFlush(entity);
    saved.setId(null);

    exception.expect(JpaSystemException.class);

    repository.saveAndFlush(saved);
}
 
开发者ID:nus-ncl,项目名称:services-in-one,代码行数:11,代码来源:RealizationRepositoryTest.java

示例9: testSaveWithExistingEntityWithNullId

import org.springframework.orm.jpa.JpaSystemException; //导入依赖的package包/类
@Test
public void testSaveWithExistingEntityWithNullId() throws Exception {
    final UserEntity entity = TestUtil.getUserEntity();
    final UserEntity saved = repository.saveAndFlush(entity);
    saved.setId(null);

    exception.expect(JpaSystemException.class);

    repository.saveAndFlush(saved);
}
 
开发者ID:nus-ncl,项目名称:services-in-one,代码行数:11,代码来源:UserRepositoryTest.java

示例10: testSaveNullId

import org.springframework.orm.jpa.JpaSystemException; //导入依赖的package包/类
@Test
public void testSaveNullId() throws Exception {
    final CredentialsEntity entity = getCredentialsEntity();
    entity.setId(null);

    exception.expect(JpaSystemException.class);
    exception.expectMessage(CredentialsEntity.class.getName());

    repository.saveAndFlush(entity);
}
 
开发者ID:nus-ncl,项目名称:services-in-one,代码行数:11,代码来源:CredentialsRepositoryTest.java

示例11: testSaveWithExistingEntityWithNullId

import org.springframework.orm.jpa.JpaSystemException; //导入依赖的package包/类
@Test
public void testSaveWithExistingEntityWithNullId() throws Exception {
    final ImageEntity entity = getImageEntity();
    final ImageEntity saved = repository.saveAndFlush(entity);
    saved.setId(null);

    exception.expect(JpaSystemException.class);

    repository.saveAndFlush(saved);
}
 
开发者ID:nus-ncl,项目名称:services-in-one,代码行数:11,代码来源:ImageRepositoryTest.java

示例12: testSaveWithExistingEntityWithNullId

import org.springframework.orm.jpa.JpaSystemException; //导入依赖的package包/类
@Test
public void testSaveWithExistingEntityWithNullId() throws Exception {
    final ExperimentEntity entity = getExperimentEntity();
    final ExperimentEntity saved = repository.saveAndFlush(entity);
    saved.setId(null);

    exception.expect(JpaSystemException.class);

    repository.saveAndFlush(saved);
}
 
开发者ID:nus-ncl,项目名称:services-in-one,代码行数:11,代码来源:ExperimentRepositoryTest.java

示例13: testSaveWithExistingEntityWithNullId

import org.springframework.orm.jpa.JpaSystemException; //导入依赖的package包/类
@Test
public void testSaveWithExistingEntityWithNullId() throws Exception {
    final DeterLabProjectEntity entity = Util.getDeterLabProjectEntity();
    final DeterLabProjectEntity saved = repository.saveAndFlush(entity);
    saved.setId(null);

    exception.expect(JpaSystemException.class);

    repository.saveAndFlush(saved);
}
 
开发者ID:nus-ncl,项目名称:services-in-one,代码行数:11,代码来源:DeterLabProjectRepositoryTest.java

示例14: testSaveWithExistingEntityWithNullId

import org.springframework.orm.jpa.JpaSystemException; //导入依赖的package包/类
@Test
public void testSaveWithExistingEntityWithNullId() throws Exception {
    final DeterLabUserEntity entity = Util.getDeterlabUserEntity();
    final DeterLabUserEntity saved = repository.saveAndFlush(entity);
    saved.setId(null);

    exception.expect(JpaSystemException.class);

    repository.saveAndFlush(saved);
}
 
开发者ID:nus-ncl,项目名称:services-in-one,代码行数:11,代码来源:DeterLabUserRepositoryTest.java

示例15: testCreateStudentsWithNonUniqueIds

import org.springframework.orm.jpa.JpaSystemException; //导入依赖的package包/类
@Test(expected = JpaSystemException.class)
public void testCreateStudentsWithNonUniqueIds() {        
    Student student1 = new Student();
    student1.setUniqueId("4113947bec18b7ad_1");
    studentDao.create(student1);
    
    Student student2 = new Student();
    student2.setUniqueId("4113947bec18b7ad_1");
    studentDao.create(student2);
}
 
开发者ID:elimu-ai,项目名称:webapp,代码行数:11,代码来源:StudentDaoTest.java


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