reports-service: http://jira.mfd.msk:8088/browse/CLS-711 fix getSingleObjectById for DBMap

This commit is contained in:
akulikov 2024-08-22 16:56:26 +03:00
parent 5a2607607e
commit 048eba8b11

View file

@ -47,14 +47,15 @@ public class DBMap<T extends SpcexObjectBase> implements Imdg<T> {
@Override
public T getSingleObjectByID(Long id) {
T result;
List<T> result;
try {
result = jdbcTemplate.queryForObject("select * from %s where ID = %d".formatted(tableName, id), reflectionRowMapper);
result = jdbcTemplate.query("select * from %s where ID = %d limit 1".formatted(tableName, id), reflectionRowMapper);
} catch (Exception e) {
log.warn("Query error", e);
return null;
}
return result;
if (result.isEmpty()) return null;
return result.iterator().next();
}
@Override