Only log about records with duplicate pump id.
This commit is contained in:
parent
409acd0721
commit
ca003fbdd7
1 changed files with 8 additions and 10 deletions
|
@ -381,16 +381,14 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
QueryBuilder<Treatment, Long> queryBuilder = getDao().queryBuilder();
|
QueryBuilder<Treatment, Long> queryBuilder = getDao().queryBuilder();
|
||||||
Where where = queryBuilder.where();
|
Where where = queryBuilder.where();
|
||||||
where.eq("pumpId", pumpId);
|
where.eq("pumpId", pumpId);
|
||||||
PreparedQuery<Treatment> preparedQuery = queryBuilder.prepare();
|
queryBuilder.orderBy("date", true);
|
||||||
List<Treatment> result = getDao().query(preparedQuery);
|
|
||||||
switch (result.size()) {
|
List<Treatment> result = getDao().query(queryBuilder.prepare());
|
||||||
case 0:
|
if (result.isEmpty())
|
||||||
return null;
|
return null;
|
||||||
case 1:
|
if (result.size() > 1)
|
||||||
|
log.warn("Multiple records with the same pump id found (returning first one): " + result.toString());
|
||||||
return result.get(0);
|
return result.get(0);
|
||||||
default:
|
|
||||||
throw new RuntimeException("Multiple records with the same pump id found: " + result.toString());
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue