Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/model/BedHeight.java @ 9098:32dd7e761e4e
Fixed condition for Query.list result (checking isEmpty added)
author | mschaefer |
---|---|
date | Mon, 28 May 2018 10:56:57 +0200 |
parents | 02e4a0d983c0 |
children | aca5a7a57a3a |
comparison
equal
deleted
inserted
replaced
9097:82917e414d76 | 9098:32dd7e761e4e |
---|---|
238 | 238 |
239 query.setParameter("id", id); | 239 query.setParameter("id", id); |
240 | 240 |
241 final List<BedHeight> singles = query.list(); | 241 final List<BedHeight> singles = query.list(); |
242 | 242 |
243 return singles != null ? singles.get(0) : null; | 243 return ((singles != null) && !singles.isEmpty()) ? singles.get(0) : null; |
244 } | 244 } |
245 | 245 |
246 public static BedHeight getBedHeightByDescription(final River river, final String description) { | 246 public static BedHeight getBedHeightByDescription(final River river, final String description) { |
247 | 247 |
248 final Session session = SessionHolder.HOLDER.get(); | 248 final Session session = SessionHolder.HOLDER.get(); |
251 query.setParameter("river", river); | 251 query.setParameter("river", river); |
252 query.setParameter("description", description); | 252 query.setParameter("description", description); |
253 | 253 |
254 final List<BedHeight> singles = query.list(); | 254 final List<BedHeight> singles = query.list(); |
255 | 255 |
256 return singles != null ? singles.get(0) : null; | 256 return ((singles != null) && !singles.isEmpty()) ? singles.get(0) : null; |
257 } | 257 } |
258 } | 258 } |
259 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 259 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |