Tabnine Logo
org.springframework.dao
Code IndexAdd Tabnine to your IDE (free)

How to use org.springframework.dao

Best Java code snippets using org.springframework.dao (Showing top 20 results out of 621)

origin: spring-projects/spring-framework

/**
 * Handle the case where the ResultSet contains multiple rows.
 * @throws DataAccessException a corresponding exception,
 * by default an IncorrectResultSizeDataAccessException
 * @see org.springframework.dao.IncorrectResultSizeDataAccessException
 */
protected void handleMultipleRowsFound() throws DataAccessException {
  throw new IncorrectResultSizeDataAccessException(
      "LobStreamingResultSetExtractor found multiple rows in database", 1);
}
origin: spring-projects/spring-framework

/**
 * Handle the case where the ResultSet does not contain a row.
 * @throws DataAccessException a corresponding exception,
 * by default an EmptyResultDataAccessException
 * @see org.springframework.dao.EmptyResultDataAccessException
 */
protected void handleNoRowFound() throws DataAccessException {
  throw new EmptyResultDataAccessException(
      "LobStreamingResultSetExtractor did not find row in database", 1);
}
origin: spring-projects/spring-framework

/**
 * Create a new ArgTypePreparedStatementSetter for the given arguments.
 * @param args the arguments to set
 * @param argTypes the corresponding SQL types of the arguments
 */
public ArgumentTypePreparedStatementSetter(@Nullable Object[] args, @Nullable int[] argTypes) {
  if ((args != null && argTypes == null) || (args == null && argTypes != null) ||
      (args != null && args.length != argTypes.length)) {
    throw new InvalidDataAccessApiUsageException("args and argTypes parameters must match");
  }
  this.args = args;
  this.argTypes = argTypes;
}
origin: spring-projects/spring-framework

if (ex instanceof SQLTransientException) {
  if (ex instanceof SQLTransientConnectionException) {
    return new TransientDataAccessResourceException(buildMessage(task, sql, ex), ex);
    return new ConcurrencyFailureException(buildMessage(task, sql, ex), ex);
    return new QueryTimeoutException(buildMessage(task, sql, ex), ex);
    return new DataAccessResourceFailureException(buildMessage(task, sql, ex), ex);
    return new DataIntegrityViolationException(buildMessage(task, sql, ex), ex);
    return new DataIntegrityViolationException(buildMessage(task, sql, ex), ex);
    return new PermissionDeniedDataAccessException(buildMessage(task, sql, ex), ex);
    return new InvalidDataAccessApiUsageException(buildMessage(task, sql, ex), ex);
  return new RecoverableDataAccessException(buildMessage(task, sql, ex), ex);
origin: spring-projects/spring-security

  public UserDetails loadUserByUsername(String username) {
    throw new DataRetrievalFailureException(
        "This mock simulator is designed to fail");
  }
}
origin: spring-projects/spring-framework

@Override
public void cleanup() {
  if (this.xmlObject != null) {
    try {
      this.xmlObject.free();
    }
    catch (SQLException ex) {
      throw new DataAccessResourceFailureException("Could not free SQLXML object", ex);
    }
  }
}
origin: spring-projects/spring-framework

/**
 * Delegate method to execute the insert, generating a single key.
 */
private Number executeInsertAndReturnKeyInternal(final List<?> values) {
  KeyHolder kh = executeInsertAndReturnKeyHolderInternal(values);
  if (kh.getKey() != null) {
    return kh.getKey();
  }
  else {
    throw new DataIntegrityViolationException(
        "Unable to retrieve the generated key for the insert: " + getInsertString());
  }
}
origin: spring-projects/spring-framework

/**
 * Analogous to the SqlQuery.execute([]) method. This is a
 * generic method to execute a query, taken a number of arguments.
 * @param parameters array of parameters. These will be objects or
 * object wrapper types for primitives.
 * @return the value of the function
 */
public int run(Object... parameters) {
  Object obj = super.findObject(parameters);
  if (!(obj instanceof Number)) {
    throw new TypeMismatchDataAccessException("Couldn't convert result object [" + obj + "] to int");
  }
  return ((Number) obj).intValue();
}
origin: spring-projects/spring-framework

  @Override
  public String doInTransaction(TransactionStatus status) {
    assertTrue(TransactionSynchronizationManager.isSynchronizationActive());
    assertTrue(TransactionSynchronizationManager.isActualTransactionActive());
    assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly());
    throw new OptimisticLockingFailureException("");
  }
});
origin: spring-projects/spring-framework

@Override
public DataAccessException translate(String task, @Nullable String sql, SQLException ex) {
  if (ex.getErrorCode() == 2) {
    return new TransientDataAccessResourceException("Custom", ex);
  }
  return null;
}
origin: spring-projects/spring-framework

/**
 * Set whether prepared statements should be capable of returning
 * auto-generated keys.
 * @see java.sql.Connection#prepareStatement(String, int)
 */
public void setReturnGeneratedKeys(boolean returnGeneratedKeys) {
  if (isCompiled()) {
    throw new InvalidDataAccessApiUsageException(
        "The returnGeneratedKeys flag must be set before the operation is compiled");
  }
  this.returnGeneratedKeys = returnGeneratedKeys;
}
origin: spring-projects/spring-framework

@Override
protected final Record createInputRecord(RecordFactory recordFactory, Object inObject) {
  try {
    return new CommAreaRecord(objectToBytes(inObject));
  }
  catch (IOException ex) {
    throw new DataRetrievalFailureException("I/O exception during bytes conversion", ex);
  }
}
origin: spring-projects/spring-framework

  @Override
  public DataAccessException translateExceptionIfPossible(RuntimeException ex) {
    if (ex instanceof PersistenceException) {
      return new DataAccessResourceFailureException(ex.getMessage());
    }
    return null;
  }
}
origin: spring-projects/spring-framework

/**
 * Method to check whether we are allowed to make any configuration changes at this time.
 * If the class has been compiled, then no further changes to the configuration are allowed.
 */
protected void checkIfConfigurationModificationIsAllowed() {
  if (isCompiled()) {
    throw new InvalidDataAccessApiUsageException(
        "Configuration cannot be altered once the class has been compiled or used");
  }
}
origin: spring-projects/spring-framework

@Override
protected final Object extractOutputData(Record record) throws DataAccessException {
  CommAreaRecord commAreaRecord = (CommAreaRecord) record;
  try {
    return bytesToObject(commAreaRecord.toByteArray());
  }
  catch (IOException ex) {
    throw new DataRetrievalFailureException("I/O exception during bytes conversion", ex);
  }
}
origin: spring-projects/spring-framework

@Override
@Nullable
public Map<String, Object> getKeys() throws InvalidDataAccessApiUsageException {
  if (this.keyList.isEmpty()) {
    return null;
  }
  if (this.keyList.size() > 1) {
    throw new InvalidDataAccessApiUsageException(
        "The getKeys method should only be used when keys for a single row are returned.  " +
        "The current key list contains keys for multiple rows: " + this.keyList);
  }
  return this.keyList.get(0);
}
origin: spring-projects/spring-framework

  @Override
  public Void doInTransaction(TransactionStatus status) {
    assertTrue("Has thread connection", TransactionSynchronizationManager.hasResource(connectionFactory));
    CciTemplate ct = new CciTemplate(connectionFactory);
    ct.execute(interactionSpec, record, record);
    throw new DataRetrievalFailureException("error");
  }
});
origin: spring-projects/spring-framework

/**
 * Set whether to use statements that are capable of returning
 * updatable ResultSets.
 * @see java.sql.Connection#prepareStatement(String, int, int)
 */
public void setUpdatableResults(boolean updatableResults) {
  if (isCompiled()) {
    throw new InvalidDataAccessApiUsageException(
        "The updateableResults flag must be set before the operation is compiled");
  }
  this.updatableResults = updatableResults;
}
origin: spring-projects/spring-framework

/**
 * Set the class that each row should be mapped to.
 */
public void setMappedClass(Class<T> mappedClass) {
  if (this.mappedClass == null) {
    initialize(mappedClass);
  }
  else {
    if (this.mappedClass != mappedClass) {
      throw new InvalidDataAccessApiUsageException("The mapped class can not be reassigned to map to " +
          mappedClass + " since it is already providing mapping for " + this.mappedClass);
    }
  }
}
origin: spring-projects/spring-framework

/**
 * Set the column names of the auto-generated keys.
 * @see java.sql.Connection#prepareStatement(String, String[])
 */
public void setGeneratedKeysColumnNames(@Nullable String... names) {
  if (isCompiled()) {
    throw new InvalidDataAccessApiUsageException(
        "The column names for the generated keys must be set before the operation is compiled");
  }
  this.generatedKeysColumnNames = names;
}
org.springframework.dao

Most used classes

  • DataAccessResourceFailureException
    Data access exception thrown when a resource fails completely: for example, if we can't connect to a
  • InvalidDataAccessApiUsageException
    Exception thrown on incorrect usage of the API, such as failing to "compile" a query object that nee
  • IncorrectResultSizeDataAccessException
    Data access exception thrown when a result was not of the expected size, for example when expecting
  • DataRetrievalFailureException
    Exception thrown if certain expected data could not be retrieved, e.g. when looking up specific data
  • DataAccessUtils
    Miscellaneous utility methods for DAO implementations. Useful with any data access technology.
  • DataIntegrityViolationException,
  • DataAccessException,
  • InvalidDataAccessResourceUsageException,
  • DuplicateKeyException,
  • PersistenceExceptionTranslationPostProcessor,
  • OptimisticLockingFailureException,
  • PersistenceExceptionTranslator,
  • QueryTimeoutException,
  • TypeMismatchDataAccessException,
  • CannotAcquireLockException,
  • ConcurrencyFailureException,
  • PermissionDeniedDataAccessException,
  • PessimisticLockingFailureException,
  • TransientDataAccessResourceException
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now