Package org.springframework.dao

Examples of org.springframework.dao.DataIntegrityViolationException


    };
    sext.setSqlErrorCodes(ERROR_CODES);
   
    // Shouldn't custom translate this
    assertEquals(customDex, sext.translate(TASK, SQL, badSqlEx));
    DataIntegrityViolationException diex = (DataIntegrityViolationException) sext.translate(TASK, SQL, intVioEx);
    assertEquals(intVioEx, diex.getCause());
  }
View Full Code Here


    assertEquals(CustomErrorCodeException.class, sext.translate(TASK, SQL, badSqlEx).getClass());
    assertEquals(badSqlEx, sext.translate(TASK, SQL, badSqlEx).getCause());

    // Shouldn't custom translate this
    SQLException invResEx = new SQLException("", "", 3);
    DataIntegrityViolationException diex = (DataIntegrityViolationException) sext.translate(TASK, SQL, invResEx);
    assertEquals(invResEx, diex.getCause());

    // Shouldn't custom translate this - invalid class
    try {
      customTranslation.setExceptionClass(String.class);
      fail("Should have thrown IllegalArgumentException");
View Full Code Here

  public void testTranslateException() {
    MockControl dialectControl = MockControl.createControl(JdoDialect.class);
    JdoDialect dialect = (JdoDialect) dialectControl.getMock();
    final JDOException ex = new JDOException();
    dialect.translateException(ex);
    dialectControl.setReturnValue(new DataIntegrityViolationException("test", ex));
    dialectControl.replay();
    try {
      JdoTemplate template = createTemplate();
      template.setJdoDialect(dialect);
      template.execute(new JdoCallback() {
View Full Code Here

    @Override
    public void createNewToken(PersistentRememberMeToken token) {
        PersistentRememberMeToken current = seriesTokens.get(token.getSeries());

        if (current != null) {
            throw new DataIntegrityViolationException("Series Id '"
                    + token.getSeries() + "' already exists!");
        }

        seriesTokens.put(token.getSeries(), token);
    }
View Full Code Here

        // Ensure there isn't an existing record for this recipient
        long permissionId = lookupPermissionId(aclDetailsHolder.getForeignKeyId(), basicAclEntry.getRecipient());

        if (permissionId != -1) {
            throw new DataIntegrityViolationException("Recipient '" + basicAclEntry.getRecipient()
                + "' already exists for aclObjectIdentity ID " + aclDetailsHolder.getForeignKeyId()
                + " (permission ID " + ")");
        }

        // Create acl_permission
View Full Code Here

    public synchronized void createNewToken(PersistentRememberMeToken token) {
        PersistentRememberMeToken current = seriesTokens.get(token.getSeries());

        if (current != null) {
            throw new DataIntegrityViolationException("Series Id '"+ token.getSeries() +"' already exists!");
        }

        seriesTokens.put(token.getSeries(), token);
    }
View Full Code Here

        for (String vwp : values) {
          Matcher m = multiValueRexp.matcher(vwp);
          if (m.find()) {
            builder.append(m.group(1));
          } else {
            throw new DataIntegrityViolationException("Multivalue attribute with digit@ pattern but no following value");
          }
        }
        attributes.put(entry.getKey(), builder.toString());
      }
    }
View Full Code Here

    private static final long serialVersionUID = 1L;

    public RollingSchedule(Long[] rollDates, String[] validInstrumentIds) {
        assert (rollDates.length == validInstrumentIds.length);
        if (rollDates.length != validInstrumentIds.length) {
            throw new DataIntegrityViolationException("Length mismatch");
        }
        for (int i = 0; i < rollDates.length; i++) {
            if (rollDates[i] != null && validInstrumentIds[i] != null)
                put(rollDates[i], validInstrumentIds[i]);
        }
View Full Code Here

            logger.debug("Policy is still processing.");
            return new ResponseEntity<Policy>(null, new HttpHeaders(), HttpStatus.ACCEPTED);
        }
        if (ResourceHelper.ProcessingStatus.ERROR.toString().equals(location)) {
            logger.debug("Policy was not created but resulted in an error.");
            throw new DataIntegrityViolationException("Unable to save Policy", new RuntimeException(
                    resourceHelper.getError(futureKey)));
        }

        logger.debug("Received notification that policy creation is completed");
        String policyNum = resourceHelper.parseKey(resourceHelper.getPermLocation(futureKey));
View Full Code Here

    }
    if (ex instanceof OptimisticLockException) {
      return new JpaOptimisticLockingFailureException((OptimisticLockException) ex);
    }
    if (ex instanceof EntityExistsException) {
      return new DataIntegrityViolationException(ex.getMessage(), ex);
    }
    if (ex instanceof TransactionRequiredException) {
      return new InvalidDataAccessApiUsageException(ex.getMessage(), ex);
    }
View Full Code Here

TOP

Related Classes of org.springframework.dao.DataIntegrityViolationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.