use of org.springframework.dao.EmptyResultDataAccessException in project CzechIdMng by bcvsolutions.
the class AbstractIntegrationTest method cleanup.
/**
* After method ends.
*
* @since 11.1.0
*/
@After
public void cleanup() {
evictCaches();
//
// delete all related long running tasks
UUID transactionId = TransactionContextHolder.getContext().getTransactionId();
//
// clean up created events
IdmEntityEventFilter eventFilter = new IdmEntityEventFilter();
eventFilter.setTransactionId(transactionId);
entityEventManager.findEvents(eventFilter, null).forEach(event -> {
try {
if (entityEventManager.getEvent(event.getId()) != null) {
entityEventManager.deleteEvent(event);
}
} catch (EmptyResultDataAccessException ex) {
// ok - already deleted asynchronously
} catch (Exception ex) {
LOG.warn("Event [{}] cannot be deleted.", event.getId(), ex);
}
});
// clean up created long running tasks by executed method
//
IdmLongRunningTaskFilter taskFilter = new IdmLongRunningTaskFilter();
taskFilter.setTransactionId(transactionId);
longRunningTaskService.find(taskFilter, null).forEach(task -> {
if (task.isRunning()) {
try {
longRunningTaskManager.interrupt(task.getId());
task = longRunningTaskService.get(task);
} catch (ResultCodeException ex) {
LOG.warn("Task [{}] cannot be interrupted.", task.getId(), ex);
}
if (task.isRunning()) {
task.setRunning(false);
task = longRunningTaskService.save(task);
}
}
if (longRunningTaskService.get(task) != null) {
longRunningTaskService.delete(task);
}
});
}
use of org.springframework.dao.EmptyResultDataAccessException in project metacat by Netflix.
the class MySqlTagService method get.
/**
* Returns the TagItem for the given <code>name</code>.
*
* @param name tag name
* @return TagItem
*/
@Transactional(readOnly = true)
public TagItem get(final String name) {
try {
return jdbcTemplate.queryForObject(SQL_GET_TAG_ITEM, new Object[] { name }, new int[] { Types.VARCHAR }, (rs, rowNum) -> {
final TagItem tagItem = new TagItem();
tagItem.setId(rs.getLong("id"));
tagItem.setName(rs.getString("name"));
tagItem.setCreatedBy(rs.getString("createdBy"));
tagItem.setLastUpdated(rs.getDate("lastUpdated"));
tagItem.setLastUpdatedBy(rs.getString("lastUpdatedBy"));
tagItem.setDateCreated(rs.getDate("dateCreated"));
tagItem.setValues(getValues(rs.getLong("id")));
return tagItem;
});
} catch (EmptyResultDataAccessException e) {
return null;
} catch (Exception e) {
final String message = String.format("Failed to get the tag for name %s", name);
log.error(message, e);
throw new UserMetadataServiceException(message, e);
}
}
use of org.springframework.dao.EmptyResultDataAccessException in project leopard by tanhaichao.
the class ExporterMysqlImpl method export.
@Override
public <T> List<T> export(Class<T> model, int start, int size) {
ExportSqlBuilder builder = new ExportSqlBuilder(model, ExportSqlBuilder.ESC_MYSQL);
String tableName = builder.getTableName();
String sql = builder.buildSql();
System.out.println(sql);
// return jdbc.queryForList(sql, model);
try {
return jdbc.getJdbcTemplate().query(sql, new ExporterLeopardBeanPropertyRowMapper<T>(model, tableName));
} catch (EmptyResultDataAccessException e) {
return null;
}
}
use of org.springframework.dao.EmptyResultDataAccessException in project leopard by tanhaichao.
the class ExporterOracleImpl method export.
@Override
public <T> List<T> export(Class<T> model, int start, int size) {
ExportSqlBuilder builder = new ExportSqlBuilder(model, ExportSqlBuilder.ESC_ORACLE);
String tableName = builder.getTableName();
String sql = builder.buildSql();
System.out.println(sql);
// return jdbc.queryForList(sql, model);
try {
return jdbc.getJdbcTemplate().query(sql, new ExporterLeopardBeanPropertyRowMapper<T>(model, tableName));
} catch (EmptyResultDataAccessException e) {
return null;
}
}
use of org.springframework.dao.EmptyResultDataAccessException in project camel by apache.
the class SqlRouteTest method testInsert.
@Test
public void testInsert() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
template.sendBody("direct:insert", new Object[] { 10, "test", "test" });
mock.assertIsSatisfied();
try {
String projectName = jdbcTemplate.queryForObject("select project from projects where id = 10", String.class);
assertEquals("test", projectName);
} catch (EmptyResultDataAccessException e) {
fail("no row inserted");
}
Integer actualUpdateCount = mock.getExchanges().get(0).getIn().getHeader(SqlConstants.SQL_UPDATE_COUNT, Integer.class);
assertEquals((Integer) 1, actualUpdateCount);
}
Aggregations