use of org.apache.ibatis.exceptions.PersistenceException in project mybatis-3 by mybatis.
the class StringListTest method shouldFailFastIfCollectionTypeIsAmbiguous.
@Test
void shouldFailFastIfCollectionTypeIsAmbiguous() throws Exception {
try (Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/stringlist/mybatis-config-invalid.xml")) {
new SqlSessionFactoryBuilder().build(reader);
fail("Should throw exception when collection type is unresolvable.");
} catch (PersistenceException e) {
assertTrue(e.getMessage().contains("Ambiguous collection type for property 'groups'. You must specify 'javaType' or 'resultMap'."));
}
}
use of org.apache.ibatis.exceptions.PersistenceException in project sonarqube by SonarSource.
the class ThreadLocalSettingsTest method getProperties_returns_empty_if_DB_error_on_first_call_ever_in_thread_cache.
@Test
public void getProperties_returns_empty_if_DB_error_on_first_call_ever_in_thread_cache() {
SettingLoader settingLoaderMock = mock(SettingLoader.class);
PersistenceException toBeThrown = new PersistenceException("Faking an error connecting to DB");
doThrow(toBeThrown).when(settingLoaderMock).loadAll();
underTest = new ThreadLocalSettings(new PropertyDefinitions(system), new Properties(), settingLoaderMock);
underTest.load();
assertThat(underTest.getProperties()).isEmpty();
}
use of org.apache.ibatis.exceptions.PersistenceException in project taskana by Taskana.
the class ClassificationQueryImpl method list.
@Override
public List<ClassificationSummary> list(int offset, int limit) {
LOGGER.debug("entry to list(offset = {}, limit = {}), this = {}", offset, limit, this);
List<ClassificationSummary> result = null;
try {
taskanaEngine.openConnection();
RowBounds rowBounds = new RowBounds(offset, limit);
result = taskanaEngine.getSqlSession().selectList(LINK_TO_SUMMARYMAPPER, this, rowBounds);
return result;
} catch (Exception e) {
if (e instanceof PersistenceException) {
if (e.getMessage().contains("ERRORCODE=-4470")) {
TaskanaRuntimeException ex = new TaskanaRuntimeException("The offset beginning was set over the amount of result-rows.", e.getCause());
ex.setStackTrace(e.getStackTrace());
throw ex;
}
}
throw e;
} finally {
taskanaEngine.returnConnection();
if (LOGGER.isDebugEnabled()) {
int numberOfResultObjects = result == null ? 0 : result.size();
LOGGER.debug("exit from list(offset,limit). Returning {} resulting Objects: {} ", numberOfResultObjects, LoggerUtils.listToString(result));
}
}
}
use of org.apache.ibatis.exceptions.PersistenceException in project taskana by Taskana.
the class WorkbasketAccessItemQueryImpl method list.
@Override
public List<WorkbasketAccessItem> list(int offset, int limit) {
LOGGER.debug("entry to list(offset = {}, limit = {}), this = {}", offset, limit, this);
List<WorkbasketAccessItem> result = new ArrayList<>();
try {
taskanaEngine.openConnection();
RowBounds rowBounds = new RowBounds(offset, limit);
List<WorkbasketAccessItemImpl> foundAccessItms = taskanaEngine.getSqlSession().selectList(LINK_TO_MAPPER, this, rowBounds);
result.addAll(foundAccessItms);
return result;
} catch (PersistenceException e) {
if (e.getMessage().contains("ERRORCODE=-4470")) {
TaskanaRuntimeException ex = new TaskanaRuntimeException("The offset beginning was set over the amount of result-rows.", e.getCause());
ex.setStackTrace(e.getStackTrace());
throw ex;
}
throw e;
} finally {
taskanaEngine.returnConnection();
if (LOGGER.isDebugEnabled()) {
int numberOfResultObjects = result == null ? 0 : result.size();
LOGGER.debug("exit from list(offset,limit). Returning {} resulting Objects: {} ", numberOfResultObjects, LoggerUtils.listToString(result));
}
}
}
use of org.apache.ibatis.exceptions.PersistenceException in project taskana by Taskana.
the class WorkbasketQueryImpl method list.
@Override
public List<WorkbasketSummary> list(int offset, int limit) {
LOGGER.debug("entry to list(offset = {}, limit = {}), this = {}", offset, limit, this);
List<WorkbasketSummary> workbaskets = null;
try {
taskanaEngine.openConnection();
RowBounds rowBounds = new RowBounds(offset, limit);
handleCallerRolesAndAccessIds();
workbaskets = taskanaEngine.getSqlSession().selectList(LINK_TO_MAPPER, this, rowBounds);
return workbaskets;
} catch (PersistenceException e) {
if (e.getMessage().contains("ERRORCODE=-4470")) {
TaskanaRuntimeException ex = new TaskanaRuntimeException("The offset beginning was set over the amount of result-rows.", e.getCause());
ex.setStackTrace(e.getStackTrace());
throw ex;
}
throw e;
} finally {
taskanaEngine.returnConnection();
if (LOGGER.isDebugEnabled()) {
int numberOfResultObjects = workbaskets == null ? 0 : workbaskets.size();
LOGGER.debug("exit from list(offset,limit). Returning {} resulting Objects: {} ", numberOfResultObjects, LoggerUtils.listToString(workbaskets));
}
}
}
Aggregations