reports-service: http://jira.mfd.msk:8088/browse/CLS-711 fix getSingleObjectById for DBMap
This commit is contained in:
parent
5a2607607e
commit
048eba8b11
1 changed files with 4 additions and 3 deletions
|
|
@ -47,14 +47,15 @@ public class DBMap<T extends SpcexObjectBase> implements Imdg<T> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T getSingleObjectByID(Long id) {
|
public T getSingleObjectByID(Long id) {
|
||||||
T result;
|
List<T> result;
|
||||||
try {
|
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) {
|
} catch (Exception e) {
|
||||||
log.warn("Query error", e);
|
log.warn("Query error", e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return result;
|
if (result.isEmpty()) return null;
|
||||||
|
return result.iterator().next();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue