throw new DataException( message, sqlException, sql );
return new DataIntegrityViolationException(ex.getMessage() + "; SQL [" + jdbcEx.getSQL() + "]", ex);
private AnnotationData addAnnotationCommon(final Annotation annotation, final String userId, final String parentId, String topParentId, String targetId, final String eventTag) { if (annotation.getId() == null) { throw new InvalidAnnotationException(annotation.getId(), "Annotation has no ID"); } final AnnotationHibernateModel hibernateModel = new AnnotationHibernateModel(); setCommonHibernateModel(userId, parentId, topParentId, targetId, hibernateModel); hibernateModel.setCreatorId(userId); hibernateModel.setCreationDate(hibernateModel.getEditionDate()); hibernateModel.fillDaoWithDataFromAnnotation(annotation); final AnnotationHibernateModel potentialSame = getNewestAnnotationForId(hibernateModel.getKey().getId()); if (potentialSame != null) { throw new AnnotationWithThisIdAlreadyExistException(annotation.getId()); } try { logger.debug("save annotaiotion {}", hibernateModel); AnnotationIdentifier annId = (AnnotationIdentifier) hibernateTemplate.save(hibernateModel); saveEvent(annId.getId(), annotation.getState().equals(AnnotationStateConstants.DELETED), eventTag); } catch (DataException dae) { dae.getCause().printStackTrace(); } return hibernateModel.translateToAnnotationData(); }
return new DataIntegrityViolationException(ex.getMessage() + "; SQL [" + jdbcEx.getSQL() + "]", ex);
/** * Convert the given SQLException into Hibernate's JDBCException hierarchy. * * @param sqlException The SQLException to be converted. * @param message An optional error message. * @param sql Optionally, the sql being performed when the exception occurred. * @return The resulting JDBCException; returns null if it could not be converted. */ @Override public JDBCException convert(SQLException sqlException, String message, String sql) { String sqlStateClassCode = JdbcExceptionHelper.extractSqlStateClassCode( sqlException ); if ( sqlStateClassCode != null ) { Integer errorCode = JdbcExceptionHelper.extractErrorCode( sqlException ); if ( INTEGRITY_VIOLATION_CATEGORIES.contains( errorCode ) ) { String constraintName = getConversionContext() .getViolatedConstraintNameExtracter() .extractConstraintName( sqlException ); return new ConstraintViolationException( message, sqlException, sql, constraintName ); } else if ( DATA_CATEGORIES.contains( sqlStateClassCode ) ) { return new DataException( message, sqlException, sql ); } } return null; // allow other delegates the chance to look } }
return new DataIntegrityViolationException(ex.getMessage() + "; SQL [" + jdbcEx.getSQL() + "]", ex);
return new DataException( message, sqlException, sql );
return new DataIntegrityViolationException(ex.getMessage() + "; SQL [" + jdbcEx.getSQL() + "]", ex);
@Override public JDBCException convert(SQLException sqlException, String message, String sql) { final String sqlState = JdbcExceptionHelper .extractSqlState(sqlException); if (sqlState != null) { if (SQL_GRAMMAR_CATEGORIES.contains(sqlState)) { return new SQLGrammarException(message, sqlException, sql); } else if (DATA_CATEGORIES.contains(sqlState)) { return new DataException(message, sqlException, sql); } else if (LOCK_ACQUISITION_CATEGORIES.contains(sqlState)) { return new LockAcquisitionException(message, sqlException, sql); } } return null; } };
@Override public JDBCException convert(SQLException sqlException, String message, String sql) { final String sqlState = JdbcExceptionHelper .extractSqlState(sqlException); if (sqlState != null) { if (SQL_GRAMMAR_CATEGORIES.contains(sqlState)) { return new SQLGrammarException(message, sqlException, sql); } else if (DATA_CATEGORIES.contains(sqlState)) { return new DataException(message, sqlException, sql); } else if (LOCK_ACQUISITION_CATEGORIES.contains(sqlState)) { return new LockAcquisitionException(message, sqlException, sql); } } return null; } };
return new DataIntegrityViolationException(ex.getMessage() + "; SQL [" + jdbcEx.getSQL() + "]", ex);
@Override public JDBCException convert(SQLException sqlException, String message, String sql) { final int errorCode = JdbcExceptionHelper.extractErrorCode( sqlException ) & 0xFF; if (errorCode == SQLITE_TOOBIG || errorCode == SQLITE_MISMATCH) { return new DataException( message, sqlException, sql ); } else if (errorCode == SQLITE_BUSY || errorCode == SQLITE_LOCKED) { return new LockAcquisitionException( message, sqlException, sql ); } else if ((errorCode >= SQLITE_IOERR && errorCode <= SQLITE_PROTOCOL) || errorCode == SQLITE_NOTADB) { return new JDBCConnectionException( message, sqlException, sql ); } // returning null allows other delegates to operate return null; } };
throw new DataException( message, sqlException, sql );
return new DataIntegrityViolationException(ex.getMessage() + "; SQL [" + jdbcEx.getSQL() + "]", ex);
throw new DataException( message, sqlException, sql );
return new DataIntegrityViolationException(ex.getMessage() + "; SQL [" + jdbcEx.getSQL() + "]", ex);
throw new DataException( message, sqlException, sql );
@Override public JDBCException convert(SQLException sqlException, String message, String sql) { final int errorCode = sqlException.getErrorCode(); if (errorCode == SQLITE_CONSTRAINT) { final String constraintName = EXTRACTER.extractConstraintName(sqlException); return new ConstraintViolationException(message, sqlException, sql, constraintName); } else if (errorCode == SQLITE_TOOBIG || errorCode == SQLITE_MISMATCH) { return new DataException(message, sqlException, sql); } else if (errorCode == SQLITE_BUSY || errorCode == SQLITE_LOCKED) { return new LockAcquisitionException(message, sqlException, sql); } else if ((errorCode >= SQLITE_IOERR && errorCode <= SQLITE_PROTOCOL) || errorCode == SQLITE_NOTADB) { return new JDBCConnectionException(message, sqlException, sql); } return new GenericJDBCException(message, sqlException, sql); } };