Mercurial > dive4elements > river
changeset 9098:32dd7e761e4e
Fixed condition for Query.list result (checking isEmpty added)
author | mschaefer |
---|---|
date | Mon, 28 May 2018 10:56:57 +0200 |
parents | 82917e414d76 |
children | 850ce16034e9 |
files | backend/src/main/java/org/dive4elements/river/model/BedHeight.java backend/src/main/java/org/dive4elements/river/model/sinfo/FlowDepthColumn.java backend/src/main/java/org/dive4elements/river/model/sinfo/Tkh.java backend/src/main/java/org/dive4elements/river/model/sinfo/TkhColumn.java |
diffstat | 4 files changed, 5 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/backend/src/main/java/org/dive4elements/river/model/BedHeight.java Mon May 28 10:54:41 2018 +0200 +++ b/backend/src/main/java/org/dive4elements/river/model/BedHeight.java Mon May 28 10:56:57 2018 +0200 @@ -240,7 +240,7 @@ final List<BedHeight> singles = query.list(); - return singles != null ? singles.get(0) : null; + return ((singles != null) && !singles.isEmpty()) ? singles.get(0) : null; } public static BedHeight getBedHeightByDescription(final River river, final String description) { @@ -253,7 +253,7 @@ final List<BedHeight> singles = query.list(); - return singles != null ? singles.get(0) : null; + return ((singles != null) && !singles.isEmpty()) ? singles.get(0) : null; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : \ No newline at end of file
--- a/backend/src/main/java/org/dive4elements/river/model/sinfo/FlowDepthColumn.java Mon May 28 10:54:41 2018 +0200 +++ b/backend/src/main/java/org/dive4elements/river/model/sinfo/FlowDepthColumn.java Mon May 28 10:56:57 2018 +0200 @@ -122,6 +122,6 @@ final Query query = session.createQuery("FROM FlowDepthColumn WHERE id=:id"); query.setParameter("id", id); final List<FlowDepthColumn> rows = query.list(); - return (rows != null) ? rows.get(0) : null; + return ((rows != null) && !rows.isEmpty()) ? rows.get(0) : null; } }
--- a/backend/src/main/java/org/dive4elements/river/model/sinfo/Tkh.java Mon May 28 10:54:41 2018 +0200 +++ b/backend/src/main/java/org/dive4elements/river/model/sinfo/Tkh.java Mon May 28 10:56:57 2018 +0200 @@ -237,6 +237,6 @@ final Query query = session.createQuery("FROM Tkh WHERE id=:id"); query.setParameter("id", id); final List<Tkh> rows = query.list(); - return (rows != null) ? rows.get(0) : null; + return ((rows != null) && !rows.isEmpty()) ? rows.get(0) : null; } } \ No newline at end of file
--- a/backend/src/main/java/org/dive4elements/river/model/sinfo/TkhColumn.java Mon May 28 10:54:41 2018 +0200 +++ b/backend/src/main/java/org/dive4elements/river/model/sinfo/TkhColumn.java Mon May 28 10:56:57 2018 +0200 @@ -116,6 +116,6 @@ final Query query = session.createQuery("FROM TkhColumn WHERE id=:id"); query.setParameter("id", id); final List<TkhColumn> rows = query.list(); - return (rows != null) ? rows.get(0) : null; + return ((rows != null) && !rows.isEmpty()) ? rows.get(0) : null; } }