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
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue