I have following table:
create table INTERNATIONALIZATION (
ID number not null unique,
LANG char(2) not null,
EXT_ID number not null,
EXT_COLUMN char(32) not null,
EXT_NAME char(32) not null,
TRANS_VAL nvarchar2(512) not null
);
And following code that aims to retrieve one and only one result from it (I am 100% sure that record exists).
public Optional<String> getTranslation(long idSkill, Locale lang, String extColumn, String extName) {
try {
return Optional.of(jdbcTemplate.queryForObject("select TRANS_VAL from INTERNATIONALIZATION where ext_id = ? and lang = ? and ext_column = ? and ext_name = ?", String.class, idSkill, lang.toLanguageTag(), extColumn, extName));
} catch (IncorrectResultSizeDataAccessException ex) {
return Optional.empty();
}
}
The problem is that when I always get the Optional.empty()
as the IncorrectResultSizeDataAccessException
is thrown, because no records are found.
When I execute this sql query in Oracle SQL Developer, I get the correct result.
What is causing this problem? Could it have something to do with nvarchar2
type of desired column?